projects
/
ieee754fpu.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
e510df5
)
little trick when it comes to if else and a return statement:
author
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Sun, 28 Apr 2019 13:43:51 +0000
(14:43 +0100)
committer
Luke Kenneth Casson Leighton
<lkcl@lkcl.net>
Sun, 28 Apr 2019 13:43:51 +0000
(14:43 +0100)
remove the else and reduce the indentation a bit
src/add/fsqrt.py
patch
|
blob
|
history
diff --git
a/src/add/fsqrt.py
b/src/add/fsqrt.py
index 60aa7e02b23274a97b11c18e669447135ecbbfb8..cb6a8ac03f849e70346ed9ff5a69075f130f1aa2 100644
(file)
--- a/
src/add/fsqrt.py
+++ b/
src/add/fsqrt.py
@@
-48,9
+48,8
@@
def main(mantissa, exponent):
if exponent & 1 != 0:
return sqrt(mantissa << 1), # shift mantissa up
((exponent - 1) / 2) # subtract 1 from exp to compensate
- else:
- return sqrt(mantissa), # mantissa as-is
- (exponent / 2) # no compensating needed on exp
+ return sqrt(mantissa), # mantissa as-is
+ (exponent / 2) # no compensating needed on exp
for Q in range(1, int(1e7)):
print(Q, sqrt(Q), sqrtsimple(Q), int(Q**0.5))