Re: a print bug?



Steve Holden wrote:
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 ;-)

hm, actually, i understand the limitation of floating point.
but my real concern is, how come "print" favors one version over the
other...
the first version will favor the correct rounding, while the second
doesn't favor it. to me, this is biased computing.... i will feel
happier if the behavior is consistent. (such as the first line
printing out as 1.2344999999999) . if most people favor the behavior
of line 1, that is, silently rounding off to about the 11th decimal
places, then why doesn't printing with formatting also use that same
behavior, which is rounding off to the 11th places first, and then
round off to whatever the user wants.

print 1.2345

1.2345

print "%10.3f" % 1.2345

1.234

but then again, i just realize even if i do a

round(1.2344999999999999999, 6)

1.2344999999999999

so even if you round it off, it is still represented the same way....
still, how "print" handles 1.2345 and treating it and printing it as
1.2345, i wonder why we don't make the "print with formatting" the same
behavior, treating it as 1.2345 first and round it off to 1.235

.



Relevant Pages

  • Re: Win32Forth & negative zero
    ... Any rounding or truncation of floating-point numbers is ... Surely this can't reasonably agree with the specifications of ... how about specifying a wordset with such functions in Forth? ...
    (comp.lang.forth)
  • Re: Rounding a floating point number
    ... double roundto(double x, int digits) ... if (digits> DBL_DIG) ... rounding the value 1.2345 to 2 decimal ... What is the purpose of rounding a floating-point value to N decimal ...
    (comp.lang.c)
  • Re: It doesnt add up - Its driving me crazy
    ... says rounding and precision in Excel. ... Floating-Point Arithmetic May Give Inaccurate Results ... Rounding Errors In Visual Basic For Applications ... "Francis Hayes (The Excel Addict)" ...
    (microsoft.public.excel.programming)
  • Re: System.Windows.Rect bug
    ... I agree with everything that Tom has written with one caveat. ... That is the suggestion to use rounding when comparing floating point values. ... explanation of the various issues faced by floating-point arithmetic on ... exactly represented in the binary representation that all modern computers ...
    (microsoft.public.dotnet.framework)
  • Re: Round float to X significant digits
    ... > I'm trying to round a double to a particular number of significant ... > digits, in this case 5, but I can't figure out a way around getting ... > Unfortunately, I need this number in floating-point, or at least I'll ... actual: somenumber = 2453126.7227099999 ...
    (comp.lang.cpp)