String math: Whole # powers easy, decimal powers!!! - Printable Version +- QB64 Phoenix Edition (https://staging.qb64phoenix.com) +-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11) +--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2) +--- Thread: String math: Whole # powers easy, decimal powers!!! (/showthread.php?tid=881) |
String math: Whole # powers easy, decimal powers!!! - Pete - 09-12-2022 I was considering adding powers to my growing string math routines, until I thought about how to handle decimal powers. For instance: 256^2.25 A pseudo algorithm to handle this crap would go something like... 256^2+25/100 ' Make into a fraction. 256^2+1/4 ' Reduce by GCF. 256^9/4 ' Combine whole number as a fraction with the fraction. (256^1/4)^9 ' Move the largest whole number outside the equation. (4 root of 256)^9 ' Apply root calculation. 4^9 = 262,144 Anyway, not to bad, until you get into even something not a whole lot more complicated than log2 of 10 or 2^3.3219280948874 So ... 2^3+3219280948874/10000000000000 ' Make into a fraction. 2^3+1609640474437/5000000000000 ' Reduce by GCF. 2^16609640474437/5000000000000 ' Combine whole number as a fraction with the fraction. (2^1/5000000000000)^16609640474437 ' Move the largest whole number outside the equation. (5000000000000 root of 2)^16609640474437 ' Apply root calculation. Well, if you can f'ing figure out what the 5 f'tillion root of 2 is, you can raise that to the power of 16609640474437 and get 10. I mean to wipe out some digits and approximate, the 5th root of 2 is approx.1.148 and that to the power of 16.7 gets you pretty close to 10, so this should work, but now I'm wondering after doing square roots, how much more involved it would be to calculate general roots? Pete |