public static HugeInteger Parse(long raw) { HugeInteger ret = new HugeInteger(); while (raw != 0) { ret.bits.Add((byte)(raw % 10)); raw /= 10; } return ret; }
public static HugeInteger operator +(HugeInteger a, HugeInteger b) { int carry = 0; HugeInteger ret = new HugeInteger(); for (uint i = 0; i < a.Length || i < b.Length || carry != 0; i++) { int sum = a.ForceGet(i) + b.ForceGet(i) + carry; ret.bits.Add((byte)(sum % 10)); carry = sum > 9 ? 1 : 0; } return ret; }
public static HugeInteger Parse(string raw) { HugeInteger ret = new HugeInteger(); if (!raw.IsPureNumber()) { throw new ArgumentOutOfRangeException("raw"); } for (int i = raw.Length - 1; i >= 0; i--) { byte a = byte.Parse(raw.Substring(i, 1)); ret.bits.Add(a); } return ret; }