Question

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

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

Était-ce utile?

La solution

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.

Autres conseils

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

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).

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top