Re: Rounding error when doing float-to-integer
From: José Rui Faustino de Sousa (jrfsousaYETFOC_at_esoterica.pt)
Date: 10/16/03
- Next message: Matthew Nobes: "Re: intel compiler problem"
- Previous message: Dr Chaos: "Re: Rounding error when doing float-to-integer"
- In reply to: Richard Maine: "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: Thu, 16 Oct 2003 22:05:48 +0100
"Richard Maine" <nospam@see.signature> wrote in message
> In particular, there is no "round to seven
> significant figures" step. What there is instead is a convert to
> binary step.
>
Yes you are both right. I was wrong.
The fact that it perfectly explained the results and that a few extra
tests I run seemed to confirm this blinded me to more carefully check
the binary representation.
> 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.
>
I know my whole case was based on that.
> 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.
>
No. I said that the rounding error was due to first rounding to seven
decimal digits and then converting to binary.
Well at least that was what I intended to say :-(
> Instead, the rounding error almost certainly comes from the
> conversion of the 0.002 to binary, which you seem to be ignoring.
>
No I am not ignoring it, the rounding error alone does not seem to
explain the result it had to be a larger error.
Even if it was 2.0000001E-3 it would not give 30641.
Now returning to the problem I will advance a new explanation what is
happening is:
int(real(dprod(real(c,sp),b1),sp))
That is the double precision product of the single precision arguments
is then rounded back to single precision and then converted to integer.
The fact that real() rounds to nearest would explain the unexpected
rounding up.
I hope this time I got it right ;-)
Best regards
José Rui
-- ======================================================================== "To surrender to ignorance and call it God has always been premature, and it remains premature today." Isaac Asimov ======================================================================== mailto://jrfsousaYETFOC@esoterica.pt/ Crawler baith. UnCaps me to reply. Contact information: http://homepage.esoterica.pt/~jrfsousa/contact.html ========================================================================
- Next message: Matthew Nobes: "Re: intel compiler problem"
- Previous message: Dr Chaos: "Re: Rounding error when doing float-to-integer"
- In reply to: Richard Maine: "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
|