Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Largest data type to store numbers

I am making a scientific calculator in C# Winform application. In that I am using double to store the answers retrieved from the calculation of function e^x. But datatype double is having some limit if it exceeds then it show the overflow related error. So can you tell me what is the largest data type to store numbers in C#.

Example: 100!

like image 366
Kishan V. Shah Avatar asked Nov 30 '25 03:11

Kishan V. Shah


1 Answers

double is the largest floating point precision data type in C#. You have BigInteger, but not a BigFloat or BigDouble.

There is however in the Base Class Library on CodePlex an implementation of BigRational, which are in fact two BigIntegers:

From there website:

BigRational builds on the BigInteger introduced in .NET Framework 4 to create an arbitrary-precision rational number type. A rational number is a ratio between two integers, and in this implementation BigIntegers are used for the numerator and denominator.

like image 168
Patrick Hofman Avatar answered Dec 02 '25 17:12

Patrick Hofman