Skip to content

Instantly share code, notes, and snippets.

@akahana-1
Created April 26, 2014 14:38
Show Gist options
  • Save akahana-1/11321779 to your computer and use it in GitHub Desktop.
Save akahana-1/11321779 to your computer and use it in GitHub Desktop.
import math
def reinv_ldexp(x, n):
b = 2 if n >= 0 else 1 / 2
n *= -1 if n < 0 else 1
a = int(n)
while a > 0:
if bool(a & 1):
x *= b
b *= b
a = a >> 1
return x
if __name__ == "__main__":
print(reinv_ldexp(math.pi, 1.73))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment