|
Posted by Erland Sommarskog on 06/16/05 16:16
Bruno Panetta (bpanetta@gmail.com) writes:
> The problem is that it doesn't matter which precision I choose, the
> results is always 29.99990.
> Even with decimal(38,30). Could this be a bug in my version of SQL
> (8.00.194)?
> Thanks
8.00.194 is indeed an old version, and you should upgrade to SP4. Get it
from http://www.microsoft.com/sql/downloads/2000/sp4.asp.
However, as I tried to explain, the operation you are trying cannot
succeed except than by chance. You *cannot* represent 3/35 as a decimal
number exactly, so you will get a rounding error. And once that rounding
error has been introduced, there is no controllable way that you can
get rid of it.
Did you try using decimal(28,10)? That worked for me in this example.
(But would may not work for other example.)
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
[Back to original message]
|