Oztaco
Oztaco

Reputation: 3459

Is there support for arbitrary precision arithmetic in C#?

Does C# support arbitrary precision arithmetic (I think this is also called bignums)?

If it doesn't, which libraries do support it?

Upvotes: 5

Views: 4715

Answers (3)

Eric Lippert
Eric Lippert

Reputation: 660159

You've already found the big integer; if you need big rational numbers (that is, fractions where the numerator and denominator are big integers) you can use the Rational class from the Solver library:

http://msdn.microsoft.com/en-us/library/microsoft.solverfoundation.common.rational(v=vs.93).aspx

Upvotes: 6

Kendall Frey
Kendall Frey

Reputation: 44336

There is a BigInteger structure that supports arbitrary-size integers.

http://msdn.microsoft.com/en-us/library/system.numerics.biginteger.aspx

Nothing for floating-point though.

Upvotes: 6

zmbq
zmbq

Reputation: 39023

F# has a BigNum type at Microsoft.FSharp.Math.BigNum, you should be able to use it from C# as well.

This type exists in the F# Powerpack . Download it and reference the appropriate DLL (I suppose it's FSharp.Powerpack.Dll, but you'll need a little trial and error).

Upvotes: 3

Related Questions