04-21-2023, 03:42 PM
(04-21-2023, 02:18 PM)mnrvovrfc Wrote: Could this be doable in "string math"?
Code: (Select All)double Fast_Pow(double a, double b) //fastpower originally developed by Martin Ankerl
{
int tmp = (*(1 + (int *)&a));
int tmp2 = (int)(b * (tmp - 1072632447) + 1072632447);
double p = 0.0;
*(1 + (int * )&p) = tmp2;
//p = p * a / 2.71828F ; failed attempt to auto correct the accuracy
return tmp;
}
from:
https://qb64phoenix.com/qb64wiki/index.p...#Fast_Math
EDIT: I was responding to bplus saying something about "power" function being difficult to implement if it involves fractions, is that right? But this function might not be a solution because it seems to force a cast from double-precision to same-size integer. That first statement is ugly. :/
That 2.71828F looks like e so doing powers with natural logarithm. That e does not look nearly precise enough for long digit math but maybe it doesn't need to be, I doubt it though. The rest of that code is Greek to me ;-))
My problem with powers is cutting down the digits to only significant amounts because my calc's use everything in multiplication, so keep multiplying long digits numbers and double their lengths in digits each time basically.
Still that crazy formula is summing long calculations and as the Prime number increases you expand on digits (more than? is that possible?) exponentially but you need more and more digits to get nice pretty integer answers.
b = b + ...