Maximum and minimum int and float values?

Questions and discussion about running MicroPython on a micro:bit board.
Target audience: MicroPython users with a micro:bit.
Post Reply
MicroGuy
Posts: 17
Joined: Sun Jan 17, 2021 8:31 pm

Maximum and minimum int and float values?

Post by MicroGuy » Sun Jan 17, 2021 8:41 pm

New member here... What is the range of integer and floating-point values available in MicroPython? I could not find these specifications in any online information after an hour of search time. Thanks --Jon

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Maximum and minimum int and float values?

Post by dhylands » Sun Jan 17, 2021 10:02 pm

It depends.

There are several different ways of configuring micropython.

The standard pyboard (STM32F405) has a notion of small ints which can store 31-bit signed integers. It also supports MPZ (multi-prrecision) which is essentually infinite precision integers, limited only by available memory.

MicroPython can be configured with single (32-bit) or double (64-bit) precision floating point numbers. The pyboard uses 32-bit by default since the hardware FPU supports 32-bit. You can recompile it to use double precision but then does everything in software. Other MCUs may support double precision in HW.

You can also see some configuration options here:
https://github.com/micropython/micropyt ... nfig.h#L69

MicroGuy
Posts: 17
Joined: Sun Jan 17, 2021 8:31 pm

Re: Maximum and minimum int and float values?

Post by MicroGuy » Sun Jan 17, 2021 10:08 pm

Thanks for your help, Dave. I appreciate your clarifications. --Jon

Post Reply