"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 the 70's: add 0.5 and truncate. But this would > still truncate 1.779999999 to two places, so this theory fails also. What > magic is round() doing, and should this same be done in the string interp > code?
Consulting bltinmodule.c would tell you. round(x,n) in (Python 2.4): multiplies x by 10**n adds .5 truncates divides by 10**n. Don't confuse this trick with giving us the correct result though, it's still floating point: >>> round(1.77499999999999999, 2) 1.78 -- Christopher A. Craig <[EMAIL PROTECTED]> "[Windows NT is] not about 'Where do you want to go today?'; it's more like 'Where am I allowed to go today?'" -- Mike Mitchell, NT Systems Administrator -- http://mail.python.org/mailman/listinfo/python-list
