views:

289

answers:

1

Hi

I'm writing a program in C# which suppose to calculate very small numbers. However, all my calculations are getting NaN value because they are too small for the 'double' datatype.

Is there an option in C# to deal with such situations?

Thanks, Eden.

+2  A: 

try decimal

Edit: Also, .NET 4 introduces BigInteger which could probably be used to represent whatever floating point values\data range you are trying to represent.

RedDeckWins
Being a big "integer" I don't think it is going to be able to store floating point values. You would have to use one BigInteger as a coefficient, and a second as a exponent in a form of scientific notation.
Simon P Stevens
Or you use fixed point arithmetic with an excessive precision of some 500 decimal digits.
SealedSun
SealedSun explained what I failed to explain when I suggested BigInteger, thanks.
RedDeckWins
can't use decimal. The Math.pow, and all that use double.
Eden