Saturday, February 25, 2012

Round problems in SQL 2000

declare @.valor float
set @.valor = 3695.6300000195000

select @.valor -- prints value without changes
select ROUND(@.valor,2) -- prints 3695.6300000000001

tested in different machines, instances ... etc

its giving me problems in queries where i want to specify
smaller/equal/bigger than zero.

one solution could be : select CAST(@.valor*100 as bigint)
and control the value *100 ...

but i would prefer another method.

anyone...instead of select CAST(@.valor*100 as bigint)
try select CAST(@.valor as decimal(16,2))

No comments:

Post a Comment