March 28, 2003 at 12:49 pm
i have big problem. i have a view with
decimal * real.
ex: 10.....076 * 1 = 10.....080
how can i solve the problem?
when i used decimal * cast (real as decimal)in linked access 2000 table i've got a text, although the result is decimal.
March 31, 2003 at 8:00 am
This was removed by the editor as SPAM
March 31, 2003 at 9:04 am
This is because the the "real" datatype is defined as an approximation of the number.
It is usually unnoticable, but very large numbers and very small decimal numbers cannot be represented accurately in the binary format.
a couple of examples of this are:
-------------------------------------------
declare @real1 real, @real2 real
-- Very Large
select @real1=1000000000076
select convert(bigint,@real1)
-- very small
select @real1 =0, @real2=.1
while @real1 < 2
begin
select @real1
select @real1 = @real1 + @real2
end
----------------------------------------
When you cast the real as decimal, you are just converting the approximation.
You might get a better approximation by using the float datatype, but it would still be an approximation.
This is described in the sql server help under "datatypes", and in this link:
http://research.microsoft.com/~hollasch/cgindex/coding/ieeefloat.html
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply