RE: results of division

2004-12-10 Thread Batista, Facundo
Title: RE: results of division [Paul McGuire] #- Errr?  How come round() is able to understand 1.775 #- correctly, whereas #- string interp is not?  I'm guessing that round() adds some #- small epsilon to #- the value to be rounded, or perhaps even does the brute #- force round

Re: results of division

2004-12-09 Thread Peter Hansen
Aahz wrote: In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: So, from the sounds of it, you really care about this ^don't rounding operation in the displayed values, in which case the "'%.2f' % value" approach ought to be fine. Right? I think w

Re: results of division

2004-12-09 Thread Aahz
In article <[EMAIL PROTECTED]>, Peter Hansen <[EMAIL PROTECTED]> wrote: >Brad Tilley wrote: >> Peter Hansen wrote: >>> The answer is "what are you trying to do?". The others have >>> given options and good advice, but the "right" approach >>> depends on what exactly you are doing. Is this just f

Re: results of division

2004-12-09 Thread Dan Bishop
Brad Tilley wrote: > Hello, > > What is the proper way to limit the results of division to only a few > spaces after the decimal? I don't need rocket-science like precision. > Here's an example: If your only complaint is that it's ugly to display 17 digits, then use the % operator to display how

Re: results of division

2004-12-09 Thread Donn Cave
In article <[EMAIL PROTECTED]>, Brad Tilley <[EMAIL PROTECTED]> wrote: > > Brad Tilley wrote: > > > >> What is the proper way to limit the results of division to only a few > >> spaces after the decimal? I don't need rocket-science like precision. > >> Here's an example: > >> > >> 1.775 is as e

Re: results of division

2004-12-09 Thread Christopher A. Craig
"Paul McGuire" <[EMAIL PROTECTED]> writes: > Errr? How come round() is able to understand 1.775 correctly, whereas > string interp is not? I'm guessing that round() adds some small epsilon to > the value to be rounded, or perhaps even does the brute force rounding I > learned in FORTRAN back in

Re: results of division

2004-12-09 Thread Peter Hansen
Brad Tilley wrote: Peter Hansen wrote: The answer is "what are you trying to do?". The others have given options and good advice, but the "right" approach depends on what exactly you are doing. Is this just for display purposes, or is there more significant (though perhaps not "precision-critical

Re: results of division

2004-12-09 Thread Tim Peters
[Paul McGuire] ... > >>> print "%.2f" % 1.775 > 1.77 > > Hmmm, if we rounded, I would have expected 1.775 to round up > to 1.78. Platform-dependent. 1.775 isn't exactly representable regardless, but whether exactly-half-way numbers that are exactly representable round up or truncate varies across

Re: results of division

2004-12-09 Thread Brad Tilley
Peter Hansen wrote: Brad Tilley wrote: What is the proper way to limit the results of division to only a few spaces after the decimal? I don't need rocket-science like precision. Here's an example: 1.775 is as exact as I need to be and normally, 1.70 will do. The answer is "what are you trying

Re: results of division

2004-12-09 Thread Brad Tilley
Simon Brunning wrote: On Thu, 09 Dec 2004 09:38:55 -0500, Brad Tilley <[EMAIL PROTECTED]> wrote: What is the proper way to limit the results of division to only a few spaces after the decimal? I don't need rocket-science like precision. Here's an example: 1.775 is as exact as I need to be and norma

Re: results of division

2004-12-09 Thread Paul McGuire
"Paul Rubin" wrote in message news:[EMAIL PROTECTED] > Brad Tilley <[EMAIL PROTECTED]> writes: > > What is the proper way to limit the results of division to only a few > > spaces after the decimal? I don't need rocket-science like > > precision. Here's an example: > > >

Re: results of division

2004-12-09 Thread Peter Hansen
Brad Tilley wrote: What is the proper way to limit the results of division to only a few spaces after the decimal? I don't need rocket-science like precision. Here's an example: 1.775 is as exact as I need to be and normally, 1.70 will do. The answer is "what are you trying to do?". The others

Re: results of division

2004-12-09 Thread Aahz
In article <[EMAIL PROTECTED]>, Brad Tilley <[EMAIL PROTECTED]> wrote: > >What is the proper way to limit the results of division to only a few >spaces after the decimal? I don't need rocket-science like precision. >Here's an example: > >1.775 is as exact as I need to be and normally, 1.70 will

Re: results of division

2004-12-09 Thread Paul Rubin
Brad Tilley <[EMAIL PROTECTED]> writes: > What is the proper way to limit the results of division to only a few > spaces after the decimal? I don't need rocket-science like > precision. Here's an example: > > 1.775 is as exact as I need to be and normally, 1.70 will do. "%.2f"% 1.775 -- http://m

Re: results of division

2004-12-09 Thread Simon Brunning
On Thu, 09 Dec 2004 09:38:55 -0500, Brad Tilley <[EMAIL PROTECTED]> wrote: > What is the proper way to limit the results of division to only a few > spaces after the decimal? I don't need rocket-science like precision. > Here's an example: > > 1.775 is as exact as I need to be and normally, 1.70 w