Skip to content

Commit 21c40f0

Browse files
committed
Fixed variable overwrite in math
1 parent de48327 commit 21c40f0

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

src/runtime/math.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
from lpython import i8, i16, i32, f32, i64, f64, ccall, overload
2-
1+
from lpython import ccall, f32, f64, i8, i16, i32, i64, overload
32

43
pi: f64 = 3.141592653589793238462643383279502884197
54
e: f64 = 2.718281828459045235360287471352662497757
@@ -718,10 +717,11 @@ def frexp(x:f64) -> tuple[f64,i16]:
718717
m is a float and e is an integer such that x == m * 2**e exactly.
719718
'''
720719
exponent: i16 = i16(0)
721-
while f64(fabs(x)) > f64(1.0):
720+
x_: f64 = x
721+
while f64(fabs(x_)) > f64(1.0):
722722
exponent += i16(1)
723-
x /= 2.0
724-
return x, exponent
723+
x_ /= 2.0
724+
return x_, exponent
725725

726726

727727
@overload
@@ -731,10 +731,11 @@ def frexp(x:f32) -> tuple[f32,i8]:
731731
m is a float and e is an integer such that x == m * 2**e exactly.
732732
'''
733733
exponent: i8 = i8(0)
734+
x_: f32 = x
734735
while f32(fabs(x)) > f32(1.0):
735736
exponent += i8(1)
736-
x /= f32(2.0)
737-
return x, exponent
737+
x_ /= f32(2.0)
738+
return x_, exponent
738739

739740

740741
@overload

0 commit comments

Comments
 (0)