c-ohle / RationalNumerics

.NET library for rational arithmetic based on a stack machine.
MIT License
47 stars 3 forks source link

Error BigRational.Pow #12

Open MaKeSter333 opened 1 year ago

MaKeSter333 commented 1 year ago

Console.WriteLine(BigRational.Pow(BigRational.Parse("2"), BigRational.Parse("1024")).ToString("F5000").Trim('0').Trim('.').Trim(','));

output: 179769313486231590772930519088622001011118896214832765155304275349863344832230481635579222589753905511470408352693059293915016093195361235646204211316618291270358047266252361344772967473693272614986720710237742201778406260548280080727716004012369601250654400739018446628865972481023592362912353548367809468670,72419534065285259505027929807

This answer is incorrect. Right:

179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216

mikkleini commented 10 months ago

Hit the same/similar case, but here's a simpler way to reproduce:

BigRational x;

x = BigRational.Pow((int)3, (int)3);
Debug.WriteLine(x.ToString());

x = BigRational.Pow(new BigRational(3), new BigRational(3));
Debug.WriteLine(x.ToString());

(Diagnostic console) output is:

27
26,999999999999999999999999999989…
mikkleini commented 9 months ago

Ping @c-ohle