Subject | Re: [firebird-support] Re: casting to decimal(9,2) gives different answers if used with a group by clause |
---|---|
Author | Kjell Rilbe |
Post date | 2009-04-18T05:54:25Z |
wibbleian2 wrote:
from rounding errors in the intermediate results, caused by the inherent
imprecision of all floating point datatypes. See my other post.
It's an always-present aspect of doing calculations with an approximate
datatype such as double. Again, see my other post.
understand how floating point calculations work. Then make sure you
don't use them in the wrong places, which is exctly what you're doing.
I hope my other post helps you understand what's going on and that
nothing's wrong, magic, buggy or anything like that.
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64
> > OK, so how many decimal places do the added terms require? 4? Cast toYes, it is. The problem is that your calculation using double suffers
> > that precision, then:
>
> The precision of the calculation is not the problem. The problem is that
> I have one piece of code that for a given parent does:
from rounding errors in the intermediate results, caused by the inherent
imprecision of all floating point datatypes. See my other post.
> I also have stashed in my head that "group by" appears to do someIt is a solution, because that unexpected rounding is not unexpected.
> internal rounding that I wasn't expecting so I wont be surprised if this
> happens again. I wont like it if it does, but I wont be surprised. This
> is the general solution to my question. If you can call it a solution.
It's an always-present aspect of doing calculations with an approximate
datatype such as double. Again, see my other post.
> Obviously the other solution is to persuade customers that the result ofThat is just silly (no offence meant). Start by making sure you
> multiplying lots of precise numbers together and then rounding
> arbitrarily in different places will give you rounding errors that can
> be comfortably ignored. But I've not met a user that can be persuaded of
> anything, so I'll go back to waiting for the revolution.
understand how floating point calculations work. Then make sure you
don't use them in the wrong places, which is exctly what you're doing.
I hope my other post helps you understand what's going on and that
nothing's wrong, magic, buggy or anything like that.
Kjell
--
--------------------------------------
Kjell Rilbe
DataDIA AB
E-post: kjell@...
Telefon: 08-761 06 55
Mobil: 0733-44 24 64