Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
fmt
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libraries
fmt
Commits
dd296e1d
Commit
dd296e1d
authored
Apr 28, 2018
by
Victor Zverovich
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a script to compute powers of 10
parent
0efc8a18
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
0 deletions
+16
-0
support/compute-powers.py
support/compute-powers.py
+16
-0
No files found.
support/compute-powers.py
0 → 100755
View file @
dd296e1d
#!/usr/bin/env python
# Compute 10 ** exp with exp in the range [min_exponent, max_exponent] and print
# normalized (with most-significant bit equal to 1) significands in hexadecimal.
from
__future__
import
print_function
min_exponent
=
-
348
max_exponent
=
340
step
=
8
significand_size
=
64
for
exp
in
range
(
min_exponent
,
max_exponent
+
1
,
step
):
n
=
10
**
exp
if
exp
>=
0
else
2
**
2000
/
10
**
-
exp
k
=
significand_size
+
1
# Convert to binary and round.
n
=
(
int
(
'{:0<{}b}'
.
format
(
n
,
k
)[:
k
],
2
)
+
1
)
/
2
print
(
'{:0<#16x}ull'
.
format
(
n
))
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment