Is it possible to get more than 100 decimal digits in C#?
If yes what is the necessary portion of code?
In Java there something call BigDecimal but it still can’t reach more than 55 digits.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Using J# libraries:
Download the J# Redistributable to obtain the J# class libraries. This article hints about how to use it to get ZIP-ability in your .NET projects, and explains a bit about BigDecimal, but as Ramhound explained, the article is relatively old.
After download, add the
vsjlibto your project. It didn’t work for me on .NET 4.0, but it did work on 2.0 project. It contains a BigDecimal class, among others. Not sure, however, if that gives you up to 100 decimals, but you might give it a try.Using MPIR — Multi Precision Integers and Rationals
You can download a wrapper for the MPIR library for .NET here (download version 0.2). Then, do the following:
\wrapper.*.dllto your project, make sure that on each built they are copied to your Debug or Release directory.\wrapper\xmpir.csto your projectAdd the following code to your project:
Note that the variable
sresultwill only hold the significant digits. You’ll have to add the logic for printing the exponent as well, or a bunch of zeroes.Result is
6.2230152778611417071440640537801242405902521687211671331011166147896988340353834411839448231257136169569665895551224821247160434722900390625E-60A documentation PDF file on the full MPIR library shows how to use it in more detail.