Subject | Re: Wierd math??? |
---|---|

Author | Aage Johansen |

Post date | 2003-02-20T22:26:27Z |

Joe Martinez wrote:

<<

I do understand the issues with floating point numbers. It's just that if

the SOURCE numbers all come out with 2 decimal places, I would expect their

SUM to also. I would just expect the database to add them together the

same way I would (line up the decemal points and add). It just seems like

a simple thing for it to do to get a "precise" sum from "precise" source

numbers.

did you examine the binary representation?

If the numbers were to add up to exactly zero, then every one of the

numbers (and the intermediate sums) would have to be exactly represented -

not very likely.

Also, keep in mind that addition and subtraction causes larger errors than

multiplication and divison.

Then, -8.53483950180589E-16 isn't all that bas as an approximation of zero :-)

Regards,

Aage J.

<<

I do understand the issues with floating point numbers. It's just that if

the SOURCE numbers all come out with 2 decimal places, I would expect their

SUM to also. I would just expect the database to add them together the

same way I would (line up the decemal points and add). It just seems like

a simple thing for it to do to get a "precise" sum from "precise" source

numbers.

>>Understanding floating point ... The numbers may look precise to you, but

did you examine the binary representation?

If the numbers were to add up to exactly zero, then every one of the

numbers (and the intermediate sums) would have to be exactly represented -

not very likely.

Also, keep in mind that addition and subtraction causes larger errors than

multiplication and divison.

Then, -8.53483950180589E-16 isn't all that bas as an approximation of zero :-)

Regards,

Aage J.