Why does Pow() require and return floats?
Posted: Mon Sep 18, 2006 5:14 am
Just wondering why both PB and Blitz return floats on something like:
2 ^ 24 ' Blitz
or
Pow(2,24) ; PB
BTW, PB returns the CORRECT integer portion (even though the answer is strangely a float), whereas Blitz does not.
What makes this strange to me is that it is mathematically impossible for an integer taken to the power of an integer to return a fractional result, yet both PB and Blitz do (and probably others as well, haven't checked).
Russell
p.s. Speaking of math, this could be a useful math library to incorporate into PB: http://www.tc.umn.edu/~ringx004/mapm-main.html
What's so great about this library you say? Whereas PB allows up to a dozen and a half or so digits of precision, the MAPM lib allows up to (get this):
BILLIONS of digits! (An extreme example, I know)
Now, you might be thinking "Well, that would probably take a looooooong time to process!". And you'd be right in this most extreme example, but not as long as you might think. Using smart 'FFT' (Fast Fourier Transform) and other tricks, the time can be greatly slashed.
2 ^ 24 ' Blitz
or
Pow(2,24) ; PB
BTW, PB returns the CORRECT integer portion (even though the answer is strangely a float), whereas Blitz does not.
What makes this strange to me is that it is mathematically impossible for an integer taken to the power of an integer to return a fractional result, yet both PB and Blitz do (and probably others as well, haven't checked).
Russell
p.s. Speaking of math, this could be a useful math library to incorporate into PB: http://www.tc.umn.edu/~ringx004/mapm-main.html
What's so great about this library you say? Whereas PB allows up to a dozen and a half or so digits of precision, the MAPM lib allows up to (get this):
BILLIONS of digits! (An extreme example, I know)
Now, you might be thinking "Well, that would probably take a looooooong time to process!". And you'd be right in this most extreme example, but not as long as you might think. Using smart 'FFT' (Fast Fourier Transform) and other tricks, the time can be greatly slashed.