Skip to content

Latest commit

 

History

History
52 lines (50 loc) · 880 Bytes

README.md

File metadata and controls

52 lines (50 loc) · 880 Bytes

Big Integer Example

BigInt implementation ported from old C code

Operations

  • Addition
  • Subtraction
  • Multiplication
  • Division
  • Modulo

Usage:

Initialize:

var number = new BigInt(1234);

Or

BigInt number = 1234;

Same with strings:

BigInt number = "-123456789";

Add:

var result = new BigInteger("123456789") + 123456L;
result += "999999";

Sub:

var result = new BigInteger("123456789") - 123456L;
result -= "999999";

Mul:

var result = new BigInteger("123456789") * 123456L;
result *= "999999";

Div:

var result = new BigInteger("123456789") / 123456L;
result /= "2";

Mod:

var result = new BigInteger("123456789") % 123456L;
result %= "2";

CompareTo:

var result = new BigInteger("123456789").CompareTo("12345676");