What is BigInteger and when would we use that ?
Share
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.
It’s a struct for an arbitrarily large integer, introduced in .NET 4.
You’d use it when you want to represent integers larger than
Int64/UInt64can cope with. For example, yesterday I wrote some code to normalizeSystem.Decimalvalues.System.Decimaluses a 96-bit integer to represent its mantissa, but I wanted to work with it as an integer – so I usedBigInteger.(It’s possible that I could have taken another approach just using
decimal, but that’s a different matter…)As another example, there was a question asked just 45 minutes ago about representing large integers to work with them for cryptography purposes. While real crypto algorithms probably use something more specialized and efficient, using
BigIntegerto multiply large integers together etc is a good way of showing what logically happens in crypto code.