Created
May 3, 2018 13:30
-
-
Save hcarver/634b18e4fc66fdb1360f50c271323349 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
from ctypes import c_float, c_int32, cast, byref, POINTER | |
def a(number): | |
threehalfs = 1.5 | |
x2 = number * 0.5 | |
y = c_float(number) | |
i = cast(byref(y), POINTER(c_int32)).contents.value | |
i = c_int32(0x5f3759df - (i >> 1)) | |
y = cast(byref(i), POINTER(c_float)).contents.value | |
y = y * (1.5 - (x2 * y * y)) | |
return y |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment