Number Format function
Sion Arrowsmith
siona at chiark.greenend.org.uk
Thu Feb 9 07:37:58 EST 2006
Rick Zantow <rzantow at gmail.com> wrote:
>>>> print number_format( 2312753.44500000, 2 )
>2,312,753.44
>>>> print number_format( 2312753.44500001, 2 )
>2,312,753.45
>
>I would expect the first to produce the same results as the second, but,
>I suppose because of one of floating point's features, it doesn't work
>that way.
>>> 2312753.44500000
2312753.4449999998
>>> 2312753.44500001
2312753.4450000101
So, yeah, the nature of floating points is going to make that
first one round "unexpectedly".
--
\S -- siona at chiark.greenend.org.uk -- http://www.chaos.org.uk/~sion/
___ | "Frankly I have no feelings towards penguins one way or the other"
\X/ | -- Arthur C. Clarke
her nu becomeþ se bera eadward ofdun hlæddre heafdes bæce bump bump bump
More information about the Python-list
mailing list