Re: Rounding error when doing float-to-integer
From: Richard Maine (nospam_at_see.signature)
Date: 10/16/03
- Previous message: Richard Maine: "Re: problem with pointer and module"
- In reply to: Glen Herrmannsfeldt: "Re: Rounding error when doing float-to-integer"
- Next in thread: José Rui Faustino de Sousa: "Re: Rounding error when doing float-to-integer"
- Reply: José Rui Faustino de Sousa: "Re: Rounding error when doing float-to-integer"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 16 Oct 2003 09:33:13 -0700
"Glen Herrmannsfeldt" <gah@ugcs.caltech.edu> writes:
> "José Rui Faustino de Sousa" <jrfsousaYETFOC@esoterica.pt> wrote in message
> news:bmm3eu$o4425$1@ID-134488.news.uni-berlin.de...
> > data->round (seven significant figures)....
> If you don't do it in binary, I don't think you can get the right answer.
Agree with Glenn here. In particular, there is no "round to seven
significant figures" step. What there is instead is a convert to
binary step. The rounding is to 24 binary digits. That amounts to
approximately 7 decimal digits, give or take some, depending. But
the actual rounding is in binary. Yes, it matters. In particular,
as Glenn mentioned in this case, there is probably *NOT* any rounding
error in the conversion of the integer to real, where you posit.
Instead, the rounding error almost certainly comes from the
conversion of the 0.002 to binary, which you seem to be ignoring.
The "7 decimal digits" bit is only a rough approximation that allows
you to gauge the approximate magnitude of the possible rounding
errors. In this case, since errors in the 9th significant decimal
digit would change the result, you can see that it is plausible for
rounding to introduce such an error. But if you want to compute the
actual numbers intead, you have to do it in binary.
-- Richard Maine | Good judgment comes from experience; email: my first.last at org.domain | experience comes from bad judgment. org: nasa, domain: gov | -- Mark Twain
- Previous message: Richard Maine: "Re: problem with pointer and module"
- In reply to: Glen Herrmannsfeldt: "Re: Rounding error when doing float-to-integer"
- Next in thread: José Rui Faustino de Sousa: "Re: Rounding error when doing float-to-integer"
- Reply: José Rui Faustino de Sousa: "Re: Rounding error when doing float-to-integer"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|