Hello everyone,
I'm going to use Big Float variable in Micropython(9 numbers after the 0.), after dividing between two numbers I got just 8 numbers in the result.
any information about this topic?
Thanks
Big float in Micropython (ESP32)
Re: Big float in Micropython (ESP32)
MicroPython uses regular IEEE single (or double in some ports) precision floating point. It's not an easy topic and it's mostly fairly counterintuitive.
This is a site that I see people link to a lot, https://floating-point-gui.de/ but there are lots of tutorials out there.
If you care about precision, you need to work entirely in integers, but for many situations you can get by with floats.
This is a site that I see people link to a lot, https://floating-point-gui.de/ but there are lots of tutorials out there.
If you care about precision, you need to work entirely in integers, but for many situations you can get by with floats.
-
- Posts: 30
- Joined: Mon Mar 07, 2016 11:44 pm
Re: Big float in Micropython (ESP32)
In cpython, this appears to require the bigfloat package to be installed. From Python docs, we have:
"The bigfloat package is a Python wrapper for the GNU MPFR library for arbitrary-precision floating-point reliable arithmetic."
If you really need such bigger numbers, you would have to port bigfloat module to micropython and the MPFR library to its C backends.
This could be a large amount of work.
If you only need nine digits instead of eight, a software fp implementation might make sense.
And if your micropython device is normally connected to a pc host, you might be able to implement a remote procedure call to have the
host do the calculations.
"The bigfloat package is a Python wrapper for the GNU MPFR library for arbitrary-precision floating-point reliable arithmetic."
If you really need such bigger numbers, you would have to port bigfloat module to micropython and the MPFR library to its C backends.
This could be a large amount of work.
If you only need nine digits instead of eight, a software fp implementation might make sense.
And if your micropython device is normally connected to a pc host, you might be able to implement a remote procedure call to have the
host do the calculations.
-
- Posts: 30
- Joined: Mon Mar 07, 2016 11:44 pm
Re: Big float in Micropython (ESP32)
I just noticed there is also a "decimal" module in cpython which may do what you want, i.e. more than eight decimal places.
But if it's not in micropython,you would have to port it.
But if it's not in micropython,you would have to port it.