How to handle float values โ€‹โ€‹that are greater than the maximum double value

I have values โ€‹โ€‹greater than 1.97626258336499E-323

I can't use BigInteger either, since it only processes integer values

Any help is appreciated

So the code that failed also failed with some solution given by some users:

BigValue / (Math.Pow((1 + ret), j)); 

If BigValue is something like 15000.25

ret -0.99197104212554987

And j will be approximately 500-600.

I don't understand how to use Rational Class for this too

+6
source share
5 answers

BigRational from the base class library team from Microsoft. It uses large integers to store it as fractions, but supports all kinds of operators.

When it comes to printing it as decimal, I think you need to write your own implementation for this. I wrote somewhere for this class, but I need to find it.

+1
source

Here is what might be helpful. I used it a while ago without any problems. This is the .Net BigDecimal class, you can download it from codeplex (or just look at the source):

http://bigdecimal.codeplex.com/releases/view/44790

It is written in VB.Net (.Net 4.0), but it does not matter.

An example of its use in C #: http://www.dreamincode.net/forums/blog/217/entry-2522-the-madman-scribblings/

+1
source

You will need to switch languages โ€‹โ€‹to one that has BigFloat type (for example, Haskel and Python have their own packages), and also find a third-party large floating-point library with C# binding. There was some discussion of such a binding for GNU MP , but it disappeared. You might write it!

See also this discussion for a discussion of MS BigRational. However, this is different from BigFloat.

0
source

One solution may be to make your problems in the log space.

your example will be as follows:

 exp(log(Number) - log(1-0.9999999) * 400) 
0
source

Learn how to use magazines to work with these numbers. Yes, you can use a large float pack, but this is almost always the case. You can usually get what you need using magazines.

0
source

All Articles