Python and C have frexp
and ldexp
functions (they basically go back and forth between y, and x and i in y = x*2^i).
I guess that exp
means exponent (of 2). What is the meaning of "ld" and "fr"? I see in http://pubs.opengroup.org/onlinepubs/009695399/functions/ldexp.html that "ld" could mean "load" (from mantissa/exponent form), but even this is not fully clear. I am not sure about "fr", though (http://pubs.opengroup.org/onlinepubs/9699919799/functions/frexp.html does not similarly give a clue).
So, what is the meaning of the names frexp
and ldexp
? I am hoping that this could help remembering which is which.
The C library function double ldexp(double x, int exponent) returns x multiplied by 2 raised to the power of exponent.
ldexp() method returns x * (2**i) of the given numbers x and i, which is the inverse of math.
It's very simple. As you already discovered earlier ldexp means load exponent: just multiply number by 2 raised to the power of some value. And the inverse function for ldexp which called frexp means extraction of float radix from a value:
Breaks the floating point number x into its binary significand (a floating point with an absolute value between 0.5(included) and 1.0(excluded)) and an integral exponent for 2, such that.*
ldexp and frexp function in Python came from C since old C90 standart. So, it's very old beard.
*http://www.cplusplus.com/reference/cmath/frexp/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With