array frexp(number x)
This function returns the normalized fraction. If the argument x is not zero, the normalized fraction is x times a power of two, and its absolute value is always in the range 1/2 (inclusive) to 1 (exclusive). If x is zero, then the normalized fraction is zero and zero is stored in exp.
x = mantissa * (2 ^ exponent)
printTable(frexp(16.4))
#[
1 = 0.5125
2 = 5
]#
And.. Now to show that:
16.4 = 0.5125 * (2 ^ 5)
:tada:
Edit:
Made frexp return vector2 instead of an array!
uh so what is this for?
uh so what is this for?
It is a missing mathematical function for Expression 2.
Calculates mantissa and exponent of a (double) floating-point number.
Need this badly..
P.S. Let me do it.
@CaptainPRICE I believe he's asking what is your use case
I believe he's asking what is your use case
One would be to make number->binary converter where most-significant bit is the first one..
Another one would be crypto..
And so on, like any other math func, just seems rarely used, but when you need it, you damn need it. You know what I mean ;)
Why bother, just import the whole mathlib.
just import the whole mathlib.
Right.. almost.
math.randomseed is unsafe.
So, "whole" would not be a good idea. See SandBoxes.
he didn't get it.