It is a standard IEEE-754 representation: http://en.wikipedia.org/wiki/IEEE_754. This is the same that is followed by most platforms.
In this representation, there are 53 bits available to store the precision; so the closest number to the actual number is represented. The arithmetic of floating points in interesting: This post by Wolfram Alpha: http://blog.wolfram.com/2007/09/25/arithmetic-is-hard-to-get-right/ on excel bugs is a good read, in this context. On Fri, Feb 19, 2010 at 1:29 PM, Senthil Kumaran <orsent...@gmail.com>wrote: > On Fri, Feb 19, 2010 at 12:58:03PM +0530, Asokan Pichai wrote: > > On Fri, Feb 19, 2010 at 12:37 PM, Kenneth Gonsalves <law...@au-kbc.org> > wrote: > > >>>> round(2.1667000000000001,3) > > > 2.1669999999999998 > > > > >>> print "%5.3f" %(round(2.16670000001, 3)) > > 2.167 > > > > And if you want a safer way to deal with floating point numbers and to > kind of behavior we understand while doing it with paper and pencil, > use the Decimal module. > > http://docs.python.org/library/decimal.html > > It behaves well with normal ints, floats and is supported for all > standard operations which are applicable for ints and floats. > > Decimal module was aimed towards the use-cases which deal with finance > and astronomy/ scientific computing where decimal number behavior > needs to be consistent and should not be system dependent. > > -- > Senthil > Q: What lies on the bottom of the ocean and twitches? > A: A nervous wreck. > _______________________________________________ > BangPypers mailing list > BangPypers@python.org > http://mail.python.org/mailman/listinfo/bangpypers > -- - Lp _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers