public static Floatz Pow(Floatz refA, Floatz refB) { Floatz a = refA.Clone(); Floatz b = refB.Clone(); if (a.isZero()) { return(Floatz.Constants.ZERO(a.separator)); } if (a.isOne() || b.isZero()) { return(Floatz.Constants.ONE(a.separator)); } if (b.isOne()) { return(a); } /* * 1,5 * ^1 + ^0,5 */ Floatz c = Floatz.Constants.ONE(); if (!b.isIntreagaZero()) { b = b.ToIntreaga(); c = new Floatz(a); b -= Floatz.Constants.ONE(); while (!b.isZero()) { c *= a; b -= Floatz.Constants.ONE(); //Console.WriteLine("{0}>{1}",b.ToString(),Floatz.Constants.ZERO()); } } if (!refB.isZecimalaZero()) { Floatz zec = refB.Clone().ToZecimala(); Floatz n = (Floatz.Constants.ONE() / zec); //Console.WriteLine(zec.ToString()); //Console.WriteLine(n.ToString()); Floatz xn = a.Clone(); Floatz xn1 = xn - (Pow(xn, n) - a) / (n * Pow(xn, (n - Floatz.Constants.ONE()))); Floatz dif = xn - xn1; while (Floatz.Abs(dif) > Floatz.Constants.SqrtTreshold) { Floatz powXnNM1 = Pow(xn, (n - Floatz.Constants.ONE())); xn1 = xn - ((powXnNM1 * xn) - a) / (n * powXnNM1); dif = xn - xn1; //Console.WriteLine("xn1: {0}\nxn:{1}",xn1,xn); xn = xn1.Clone(); } c *= xn1; } return(c); }