Decimal Mathematics #9821
Replies: 4 comments
-
I think you should also post your module here: https://github.com/mcauser/awesome-micropython |
Beta Was this translation helpful? Give feedback.
-
@rhubarbdog This is very cool! Just a question about the implementation though -- you've essentially implemented arbitrary precision integers from scratch in Python (which is neat!!). But MicroPython already does this for you -- by default on almost all ports, integers have no limit (i.e. So could a decimal number (i.e. your Number class) just be a python integer and a scale (i.e. offset of the decimal point). Also, did you consider implementing the arithmetic operators |
Beta Was this translation helpful? Give feedback.
-
Another related library for CircuitPython, by @jepler: https://github.com/jepler/Jepler_CircuitPython_udecimal |
Beta Was this translation helpful? Give feedback.
-
See also https://github.com/mpy-dev/micropython-decimal-number |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
if floating point numbers are letting you down because of the gaps and rounding errors try my decimal numbers class decimal.py at https://github.com/rhubarbdog/decimal-numbers . There is a version for microbit called microbit.py follow the instructions in the README.md.
See example code decimal_math.py and pi.py for python 3 and other boards and for microbit it's microbit_pi.py microbit_root.py
Beta Was this translation helpful? Give feedback.
All reactions