private static Big Power(string a, string b) { Big result = new Big(1); for (Big i = new Big(1); i <= b; i++) { result = result * a; } return(TrimZero(result)); }
public static Big Factorial(string a) { Big ab = new Big(a); Big abplusone = ab + "1"; if (Compare(a, "1") != 0) { return(new Big(1)); } string result = "1"; for (Big i = new Big(1); i < abplusone; i++) { result = (result * i).Value; } return(TrimZero(result)); }
public static bool IsFloat(Big b) { return(IsFloat(b.Value)); }
public static bool IsNegative(Big b) { return(IsNegative(b.Value)); }
public static bool IsNumeric(Big b) { return(IsNumeric(b.Value)); }
private static int Compare(Big b1, Big b2) { return(Compare(b1.Value, b2.Value)); }
private static Big Reverse(Big b) { return(Reverse(b.Value)); }
public static Big Negate(Big b) { return(Negate(b.Value)); }
private static Big Add(Big b1, Big b2) { return(Add(b1.Value, b2.Value)); }
public static Big SquareRoot(string s, string ac = "5") { Big a = new Big(ac); string buff = ""; string output = ""; Big n = new Big(0); Big c = new Big(0); if (s.Length % 2 == 1) { s = s.Insert(0, "0"); } for (Big i = new Big(0); i < a; i++) { s += "00"; } string[] pairs = new string[s.Length / 2]; for (int i = 0; i < pairs.Length * 2; i += 2) { pairs[i / 2] = s[i].ToString(); pairs[i / 2] += s[i + 1].ToString(); } Big j = new BigStr.Big(9); for (; j >= "0"; j--) { if ((j ^ "2") < pairs[0] || (j ^ "2") == pairs[0]) { break; } } n = j; output = n.ToString(); if (pairs.Length == 1) { return(new Big(output)); } buff = (new Big(pairs[0]) - (n ^ "2")).Value; Big k = new Big(0); Big pairslength = new Big(pairs.Length); for (Big i = new Big(1); i < pairslength; i++) { if (i == pairslength - a) { c = i; } buff += pairs[Convert.ToInt32(i.Value)]; string q = ""; string m = ""; for (k.Value = "9"; k >= "0"; k--) { m = (new Big(output) * "2").Value + k.ToString(); q = (m * k).Value; if (Compare(q, buff) != 0) { break; } } buff = (new Big(buff) - q).Value; output += k.ToString(); } output = output.Insert(Convert.ToInt32(c.Value), "."); return(TrimZero(output)); //return output; }
public static Big SquareRoot(Big s, Big ac) { return(SquareRoot(s.Value, ac.Value)); }
private static Big Power(Big a, Big b) { return(Power(a.Value, b.Value)); }
public static Big Factorial(Big b) { return(Factorial(b.Value)); }
private static Big Multiply(Big a, Big b) { return(Multiply(a.Value, b.Value)); }
public static bool IsEven(Big b) { return(IsEven(b.Value)); }
public static Big TrimZero(Big b) { return(TrimZero(b.Value)); }
public static bool IsOdd(Big b) { return(IsOdd(b.Value)); }
//METHODS private static Big Subtract(Big b1, Big b2) { return(Subtract(b1.Value, b2.Value)); }