Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / October 2007

Tip: Looking for answers? Try searching our database.

How can I get exact digits of a decimal value

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
basulasz - 01 Oct 2007 21:19 GMT
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...
Michael Nemtsev - 01 Oct 2007 23:10 GMT
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>
basulasz - 02 Oct 2007 05:36 GMT
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

> Hello basulasz,
>
[quoted text clipped - 23 lines]
> b> Thanks a lot...
> b>
Patrice - 02 Oct 2007 10:47 GMT
What if you try to get the decimal data type and then convert to a string ?
Else I'll try to repro...

--
Patrice

> Hi;
>
[quoted text clipped - 12 lines]
>
> Thanks a lot...
basulasz - 02 Oct 2007 11:30 GMT
how can I get decimal data type?

> What if you try to get the decimal data type and then convert to a string ?
> Else I'll try to repro...
[quoted text clipped - 18 lines]
> >
> > Thanks a lot...
Ged - 02 Oct 2007 11:39 GMT
Decimal number = Convert.ToDecimal( myReader["total"] );

Signature

Ged Moretta
www.appsense.com

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

> how can I get decimal data type?
>
[quoted text clipped - 23 lines]
>> >
>> > Thanks a lot...
Kevin Spencer - 02 Oct 2007 11:41 GMT
Decimal d = myReader.GetDecimal(myReader.GetOrdinal("total"));

Signature

HTH,

Kevin Spencer
Microsoft MVP

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

> Hi;
>
[quoted text clipped - 12 lines]
>
> Thanks a lot...
basulasz - 02 Oct 2007 12:05 GMT
Ok. I am done. Thanks...

> Decimal d = myReader.GetDecimal(myReader.GetOrdinal("total"));
>
[quoted text clipped - 14 lines]
> >
> > Thanks a lot...

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.