Re: a print bug?
- From: Steve Holden <steve@xxxxxxxxxxxxx>
- Date: Thu, 27 Jul 2006 12:39:58 +0100
Summercoolness@xxxxxxxxx wrote:
it seems that the behavior of "print" is that it will round off>>> print "%25.22f" % 1.2345
properly for any floating point imperfection, such as shown in the
first two samples. The third sample seems to be a bug? It doesn't
know how to handle the floating imperfection in this case.
1.2345
1.2344999999999999
print 1.2345
1.2345
print "%10.3f" % 1.2345 # seems like a bug ----------------------------------
1.234
print "%10.3f" % 1.23450001
1.235
print "%10.3f" % 1.2344
1.234
print "%10.3f" % 1.2346
1.235
1.2344999999999999000000
You obviously haven't yet passed your floating-point number proficiency test yet. Please restrict yourself to integers until you understand the difficulties that inaccuracies in floating-point can create ;-)
regards
Steve
--
Steve Holden +44 150 684 7255 +1 800 494 3119
Holden Web LLC/Ltd http://www.holdenweb.com
Skype: holdenweb http://holdenweb.blogspot.com
Recent Ramblings http://del.icio.us/steve.holden
.
- Follow-Ups:
- Re: a print bug?
- From: Summercoolness
- Re: a print bug?
- References:
- a print bug?
- From: Summercoolness
- a print bug?
- Prev by Date: Re: Automatic email checking - best procedures/suggestions
- Next by Date: Re: Thread Question
- Previous by thread: Re: a print bug?
- Next by thread: Re: a print bug?
- Index(es):
Relevant Pages
|