public static HugeNumber operator *(HugeNumber a, HugeNumber b) { HugeNumber num = new HugeNumber(a); num.Multiply(b); return(num); }
/// <summary> /// 计算指数 /// </summary> /// <param name="times"></param> /// <param name="precision">记录计算过程中的精度(即原数乘了10^precision倍)</param> public void Pow(int times, int precision = 0) { if (times < 0) { Reset(); } else if (times == 0) { SetABit(precision); } else { HugeNumber cache = new HugeNumber(this); HugeNumber temp = One; temp.MoveLeft(precision); SetABit(precision); int p = 0; for (int i = 0; i < 32; i++) { if ((times & (1 << i)) == 0) { continue; } while (p <= i) { temp.Multiply(cache); temp.MoveRight(precision); cache.SetValue(temp); p++; } Multiply(temp); MoveRight(precision); } } }