Skip to content

Instantly share code, notes, and snippets.

@mattroz
Created February 3, 2022 12:02
Show Gist options
  • Save mattroz/a972df23c1f4937867c49822b5c25247 to your computer and use it in GitHub Desktop.
Save mattroz/a972df23c1f4937867c49822b5c25247 to your computer and use it in GitHub Desktop.
Fast exponent in C++
inline float fast_exp(float x)
{
union {
uint32_t i;
float f;
} v{};
v.i = (1 << 23) * (1.4426950409 * x + 126.93490512f);
return v.f;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment