a print bug?



it seems that the behavior of "print" is that it will round off
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

.



Relevant Pages

  • Re: a print bug?
    ... however, in the second line, when it is round off, it doesn't know it ... exactly in radix-2 floating point arithmetic. ... 11th decimal point with a subsequent rounding off to the 3rd decimal ... the floating point imperfection is manifested. ...
    (comp.lang.python)
  • Re: a print bug?
    ... however, in the second line, when it is round off, it doesn't know it ... the floating point imperfection is manifested. ... the customer" using print "%20.2f", then there will be a cent missing ...
    (comp.lang.python)
  • Re: a print bug?
    ... The third sample seems to be a bug? ... know how to handle the floating imperfection in this case. ...
    (comp.lang.python)
  • Re: Bug in Excel 2007
    ... description of the INT function and it does say that it will round ... So when I add more decimal spaces A4 now displays 4.999999.. ... Do a google search on floating point errors if you're ... the IMO it is a bug and they probably should have used a format that doesn't ...
    (microsoft.public.excel)
  • Re: Problem With Round Function
    ... I read where they are improving accuracy of floating point ... "Ronald W. Roberts" wrote: ... >> I'm having a problem understanding the Round function. ... >> Num DecPt Answer ...
    (microsoft.public.dotnet.languages.vb)