Home > Archive > microsoft.public.sqlserver.server > June 2002 > Problem when using datatype 'Real'





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Problem when using datatype 'Real'
Patrick Foubert

2002-06-22, 8:34 pm

Hello,

I use real datatype to store numeric information, when i check requests to
my DB with sql profiler the numbers come with 2 digit precision from web
site but when are stored in db they are in full length value.

Exemple

A value of 5.40 is stored with 5.400000001 value

If i get this value and display on a web page it's displayed as 5.400000001
....

If anybody have idea.....


Dan Guzman

2002-06-22, 8:34 pm

Real and float are approximate data types. If you need an exact value
with decimals, use an exact type like decimal, money or smallmoney. See
the Books Online for details.


Hope this helps.


Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index...epartmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------

"Patrick Foubert" <patrick@webplanet.be> wrote in message
news:3d0cfe67$0$8157$ba620e4c@
news.skynet.be...
> Hello,
>
> I use real datatype to store numeric information, when i check

requests to
> my DB with sql profiler the numbers come with 2 digit precision from

web
> site but when are stored in db they are in full length value.
>
> Exemple
>
> A value of 5.40 is stored with 5.400000001 value
>
> If i get this value and display on a web page it's displayed as

5.400000001
> ...
>
> If anybody have idea.....
>
>



bruno reiter

2002-06-22, 8:34 pm

il ne faut jamais utiliser de numérique approché pour des valeurs numériques
exactes.
On ne fait jamais de test d'égalité avec du numérique approché.

br

"Patrick Foubert" <patrick@webplanet.be> wrote in message
news:3d0cfe67$0$8157$ba620e4c@
news.skynet.be...
> Hello,
>
> I use real datatype to store numeric information, when i check requests to
> my DB with sql profiler the numbers come with 2 digit precision from web
> site but when are stored in db they are in full length value.
>
> Exemple
>
> A value of 5.40 is stored with 5.400000001 value
>
> If i get this value and display on a web page it's displayed as

5.400000001
> ...
>
> If anybody have idea.....
>
>



Thierry Marneffe

2002-06-30, 11:25 am


You can use the str function to force the output of your query to be as you
want:

Select .... , str (table.Data, 5, 2) as GoodData, ......

Suppose that table.data = 5.400000001, then GoodData = 5.40

HTH

Thierry


"Patrick Foubert" <patrick@webplanet.be> wrote in message
news:3d0cfe67$0$8157$ba620e4c@
news.skynet.be...
> Hello,
>
> I use real datatype to store numeric information, when i check requests to
> my DB with sql profiler the numbers come with 2 digit precision from web
> site but when are stored in db they are in full length value.
>
> Exemple
>
> A value of 5.40 is stored with 5.400000001 value
>
> If i get this value and display on a web page it's displayed as

5.400000001
> ...
>
> If anybody have idea.....
>
>



Sponsored Links





Free Braindumps | MCSE braindumps software forum

Copyright 2003 - 2008 examnotes.net