Skip to content

Commit a0b81b1

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent a1ec88e commit a0b81b1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Diff for: maths/fast_inverse_sqrt.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,14 @@ def fast_inverse_sqrt(number: float) -> float:
3333
...
3434
ValueError: Input must be a positive number.
3535
"""
36-
if number<=0:
36+
if number <= 0:
3737
raise ValueError("Input must be a positive number.")
38-
i = struct.unpack('>i', struct.pack('>f', number))[0]
39-
i = 0x5f3759df - (i >> 1)
40-
y = struct.unpack('>f', struct.pack('>i', i))[0]
38+
i = struct.unpack(">i", struct.pack(">f", number))[0]
39+
i = 0x5F3759DF - (i >> 1)
40+
y = struct.unpack(">f", struct.pack(">i", i))[0]
4141
return y * (1.5 - 0.5 * number * y * y)
4242

43+
4344
if __name__ == "__main__":
4445
import doctest
4546

0 commit comments

Comments
 (0)