Solved

Handle significant figures in VB.NET

Posted on 2004-09-28
3
629 Views
Last Modified: 2010-08-05
Dear all,

  I am trying to handle calculation between numbers, with 25 significant figures (e.g. 123456.7890123456789012345) and seems even double can not handle figures like that.

  Are there any simple way in VB.NET to handle these kind of numbers? except cut the numbers into parts.

  Thanks.

Regs,
Bezier
0
Comment
Question by:bezier98
3 Comments
 
LVL 9

Accepted Solution

by:
checoo earned 250 total points
ID: 12167767
use decimal it can handle upto 28 significant figures
0
 
LVL 10

Assisted Solution

by:123654789987
123654789987 earned 250 total points
ID: 12168389
The decimal data type

decimal data type variables can store 1 times 10 to the 28th 1.0 × 10-28 and 7.9 times 10 to the 28 th 7.9 × 1028 in 128 bit. If you think about this type you will note that it has a greater precision and a smaller range and that’s we exactly needs for financial calculations also note that decimal data type has a Precision of 28-29 significant digits.
0
 

Author Comment

by:bezier98
ID: 12214604
Acutally I did use decimal type, but at the begining, it doesn't work, but now I know the reason.

I try the following

Dim x as decimal

x = "123456.7890123456789012345"
msgbox (x + 0.0000000000000000001)

the result will turn out to be 12345.789012346

which I think VB treated 0.0000000000000000001 as double

After assigned 0.0000000000000000001 to another decimal y, then
msgbox(x + y) will give the exact answer

Anyway, thanks for helping

Bezier
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.

791 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question