Are there functions in the Python or numpy library that take a float as input and return a decimal scientific notation decomposition, i.e. mantissa and exhibitor? Or is there a SHORT way to achieve this without resorting to string conversion or using a for loop to determine the exponent? Writing such a function will not be difficult, I am simply shocked that it is difficult for me to find the existing one in mathematics, decimal or numpy.
eg. if fexp and fman are functions that give the exponent and mantissa of a decimal floating-point number for float, then we expect all statements to return true:
fexp(154.3) == 2.0 fman(154.3) == 1.543 fexp(-1000) == 3.0 fman(-1000) == -1.0
In short, it will be the “decimal version” of math.frexp .
source share