0

Is there any type in C#that would allow me to store a fractional number with arbitrary or infinite precision? I don't want to use any external libraries--would I have to write a class myself? How would I do this?

I need a variable to which I can apply the standard arithmetic operations, and get the result with as much precision as I want, something in which I could do something like calculate pi or another irrational number to a precision like 10,000 digits...

vasilescur
  • 240
  • 2
  • 5
  • 16

1 Answers1

2

I don't want to use any external libraries--would I have to write a class myself?

I don't really get why would you implement a new library instead of using an existing one. But I would then suggest the BigRational library of Microsoft. Source codes are available as well. It uses the BigInteger type internally.

György Kőszeg
  • 17,093
  • 6
  • 37
  • 65