How can I get exact digits of a decimal value

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi;

I store decimal values in ms sql server 2005 of type decimal (28,14). When I
try to get values from that field, for example "566.68015492220000000" with
the code

string temp=myReader["total"].ToString();

I get the value "566.68010000000000000", I mean I get the value with only
few digits of precision.

What should I do to get the exact value from db?

Thanks a lot...
 
Hello basulasz,

use Math.Round(566.68015, 2)
and u will get 566.68

---
WBR,
Michael Nemtsev [.NET/C# MVP] :: blog: http://spaces.live.com/laflour

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo


b> Hi;
b>
b> I store decimal values in ms sql server 2005 of type decimal (28,14).
b> When I try to get values from that field, for example
b> "566.68015492220000000" with the code
b>
b> string temp=myReader["total"].ToString();
b>
b> I get the value "566.68010000000000000", I mean I get the value with
b> only few digits of precision.
b>
b> What should I do to get the exact value from db?
b>
b> Thanks a lot...
b>
 
I don't want to round the value. If I have "566.68015492220000000" stored in
db, I want to get "566.68015492220000000" again. But I get
"566.68010000000000000". I need the correct value, not a rounded value
 
What if you try to get the decimal data type and then convert to a string ?
Else I'll try to repro...
 
how can I get decimal data type?

Patrice said:
What if you try to get the decimal data type and then convert to a string ?
Else I'll try to repro...

--
Patrice

basulasz said:
Hi;

I store decimal values in ms sql server 2005 of type decimal (28,14). When
I
try to get values from that field, for example "566.68015492220000000"
with
the code

string temp=myReader["total"].ToString();

I get the value "566.68010000000000000", I mean I get the value with only
few digits of precision.

What should I do to get the exact value from db?

Thanks a lot...
 
Decimal number = Convert.ToDecimal( myReader["total"] );

--
Ged Moretta
www.appsense.com

-----------------------------------------------------------------------
This signature isn't automatic. I have to type it manually every time.


basulasz said:
how can I get decimal data type?

Patrice said:
What if you try to get the decimal data type and then convert to a string
?
Else I'll try to repro...

--
Patrice

"basulasz" <[email protected]> a écrit dans le message
de
Hi;

I store decimal values in ms sql server 2005 of type decimal (28,14).
When
I
try to get values from that field, for example "566.68015492220000000"
with
the code

string temp=myReader["total"].ToString();

I get the value "566.68010000000000000", I mean I get the value with
only
few digits of precision.

What should I do to get the exact value from db?

Thanks a lot...
 
Ok. I am done. Thanks...

Kevin Spencer said:
Decimal d = myReader.GetDecimal(myReader.GetOrdinal("total"));

--
HTH,

Kevin Spencer
Microsoft MVP

DSI PrintManager, Miradyne Component Libraries:
http://www.miradyne.net

basulasz said:
Hi;

I store decimal values in ms sql server 2005 of type decimal (28,14). When
I
try to get values from that field, for example "566.68015492220000000"
with
the code

string temp=myReader["total"].ToString();

I get the value "566.68010000000000000", I mean I get the value with only
few digits of precision.

What should I do to get the exact value from db?

Thanks a lot...
 
Back
Top