Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

6
  • So you mean that awk (or unix system) can't handle four digits after the point? Is that normal? In the wiki entry, they can handle to the sixth digit. Commented Jul 9, 2014 at 10:38
  • 5
    i'm saying that no IEEE754 32bit floating point number can represent certain numbers exactly (regardless whether this is unix, or w32 or whatever). you will always get an error (and the error you have is about 10^-15, this is the 15th digit, not just the sixth). the reason why you don't often see this, is because many programs do some rounding in the output. Commented Jul 9, 2014 at 11:04
  • I see. But why when the result is 1 (which is exactly 1.00000xyz), the program do rounding it, but not do so with 0.000xyz? Commented Jul 9, 2014 at 11:15
  • 1
    because print also does some rounding in order to save characters :-) now if your number is 0.000000000000000000052 you can easily print this as 5.2e-20 (takes 7 characters, rather than 24), wheras 1.000000000000000000052 is rather complicated to print (you could do 1+5.2e-20 but that is not the usual scientific notation) Commented Jul 9, 2014 at 11:22
  • @umläute: You say “… the error you have is … [in] the 15th digit, not just the sixth.” I suspect that Ooker can count. He’s saying that he would understand an approximation error for 0.1428571 or 0.12345678, but he’s questioning why 0.142857 or 0.4157 would have a problem. Commented Jul 9, 2014 at 21:09