makerofthings7
makerofthings7

Reputation: 61473

How should I store a 256 bit number in C# and perform math operations on it?

I need to store a 256bit number in memory and perform basic math operations on it.

How do I go about doing this in C#? Is there a library I should be using?

Upvotes: 3

Views: 5977

Answers (2)

Alexei Levenkov
Alexei Levenkov

Reputation: 100547

BigInteger maybe an option.

If you need just 256 bits and do special hadling of over/underflows - you may have to do it yourself (or find some existing library that is not part of .Net Framework).

Upvotes: 1

Grokys
Grokys

Reputation: 16536

Would the BigInteger type suit your needs? It

Represents an arbitrarily large signed integer.

And provides the expected arithmetic operations.

Upvotes: 7

Related Questions