Skip to content

Instantly share code, notes, and snippets.

@raberm
Created January 21, 2023 10:49
Show Gist options
  • Save raberm/cb7253ae29cabd38c117d4b436561ba8 to your computer and use it in GitHub Desktop.
Save raberm/cb7253ae29cabd38c117d4b436561ba8 to your computer and use it in GitHub Desktop.
frexp
float frexp(float x, out float e)
{
e = ceil(log2(x));
return(x * exp2(-e));
}
x = 0.15625;
x = -118.62500;
v = Ceiling[Log2[Abs[x]]] - 1
s = -(Sign[x] - 1)/2;
r = Round[(Abs[x]*2^-v - 1)*2^23];
{s, v + 127, r}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment