Last active
December 30, 2024 09:51
-
-
Save billythedummy/2aef3fe565e0e06d9d5f4319b1d7d896 to your computer and use it in GitHub Desktop.
float_to_atomics.py
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
# float_to_atomics(39.8319163, 9) = '39831916300' | |
# Does not handle integers e.g. 5000 | |
def float_to_atomics(n, atomics=9): | |
[w, d] = str(n).split(".") | |
if len(d) > atomics: | |
raise f"{n} atomics > {atomics}" | |
return "".join([w, d.ljust(atomics, '0')]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment