private static void Swap(CustomBigInt valueOne, CustomBigInt valueTwo) { CustomBigInt temp = valueOne; valueOne = valueTwo; valueTwo = temp; }
public static bool Equals(CustomBigInt valueOne, CustomBigInt valueTwo) { string elementString = valueOne.ToString(); string otherString = valueTwo.ToString(); return(elementString == otherString); }
public static CustomBigInt operator /(CustomBigInt valueOne, CustomBigInt valueTwo) { string result = string.Empty; string valueOneString = valueOne.ToString().Trim(); string valueTwoString = valueTwo.ToString().Trim(); CustomBigInt multyplyBy10 = new CustomBigInt("10"); CustomBigInt zero = new CustomBigInt("0"); if (valueOne < valueTwo) { Swap(valueOne, valueTwo); } int carry = 1; int carrySecond = 0; do { valueOne = valueOne - valueTwo; carry++; } while (valueOne > valueTwo); if (valueOne < valueTwo && valueOne != valueTwo && valueOne != zero) { carry -= 1; valueOne = valueOne * multyplyBy10; do { valueOne = valueOne - valueTwo; carrySecond++; } while (valueOne > zero); if (valueOne < valueTwo && valueOne == zero) { _isFloating = true; } } if (_isFloating) { result = carry.ToString() + "," + carrySecond.ToString(); } else { result = carry.ToString(); } return(new CustomBigInt(result)); }
private static int GetSize(CustomBigInt value) { return(value._elements.Length); }
protected bool Equals(CustomBigInt other) { return(_size == other._size && Equals(_elements, other._elements)); }