View Single Post

   
  #2 (permalink)  
Old 02-29-2008, 07:32 AM
Hugo Kornelis
 
Posts: n/a
Default Re: SQL Server 2K problem with fractional real values

On 9 Mar 2005 13:24:08 -0800, computer_prog@hotmail.com wrote:

>I have a field of type Real in my SQL 2K database. I stored a value of
>.35 in the field.

(snip)
>Why is T-SQL returning 0.34999999 for my field?


Hi computer_prog,

The datatypes real and float are for approximate numbers. The internal
representation precludes exact representation of many fractions. Just as
the value 1/3 can never be represented exactly as a fraction in our
decimal system, the value 35/100 can't be represented exactly in a float
or real datatype (but 25/100 can, incidentally).

If you need exact numeric precision, don't use float or real. Use
decimal or numeric instead.

Best, Hugo
--

(Remove _NO_ and _SPAM_ to get my e-mail address)
Reply With Quote