-
-
Save Subv/76a3e7509e6127a9838383ab3f215ecd to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unsigned int approx(float f) { | |
float ax = fabs(f); | |
unsigned int extra = 1; | |
if (ax >= 128.f) { | |
ax = 129.f; | |
extra = 0; | |
} | |
double w; | |
float ax2 = modf(ax, &w); | |
unsigned int sign = (f < 0.0f) << 31; | |
return sign | ((((int)ax) << 23) | (int)(ax2 * 8388607.f) + extra); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment