SyntaxError: decimal numbers not supported
-
- Posts: 4
- Joined: Wed Oct 14, 2015 7:34 pm
SyntaxError: decimal numbers not supported
Hello,
I have received my Wipy
However, I found the following error when I tried to type a float number in the REPL:
SyntaxError: decimal numbers not supported
Is this something temporal until a new firmware update or am I doing something wrong?
Best regards.
I have received my Wipy
However, I found the following error when I tried to type a float number in the REPL:
SyntaxError: decimal numbers not supported
Is this something temporal until a new firmware update or am I doing something wrong?
Best regards.
Re: SyntaxError: decimal numbers not supported
I don't have a WiPy yet, but it would be useful to know exactly what you typed...
It looks like the WiPy was built with:
I'm not sure if that was intentional or not.
It looks like the WiPy was built with:
Code: Select all
#define MICROPY_FLOAT_IMPL (MICROPY_FLOAT_IMPL_NONE)
Re: SyntaxError: decimal numbers not supported
Actually I've just noticed that myself...
Also I can't seem to be able to use division operation
Also I can't seem to be able to use division operation
Code: Select all
var = 4.1
SyntaxError: decimal numbers not supported
5.34 * 2
... same ...
4/2
TypeError: unsupported type for operator
Re: SyntaxError: decimal numbers not supported
/ is floating point division
// is integer division
so since floating point seems to be configured off in the WiPy, you need to use //
The teensy also doesn't have hardware floating point, but I was able to build it with software floating point. So I suspect that this will probably just require some new firmware.
// is integer division
so since floating point seems to be configured off in the WiPy, you need to use //
The teensy also doesn't have hardware floating point, but I was able to build it with software floating point. So I suspect that this will probably just require some new firmware.
- danicampora
- Posts: 342
- Joined: Tue Sep 30, 2014 7:20 am
- Contact:
Re: SyntaxError: decimal numbers not supported
Floating point takes a lot of code space that the WiPy cannot afford. Divisions need to be done with // as Dave pointed out.
-
- Posts: 4
- Joined: Wed Oct 14, 2015 7:34 pm
Re: SyntaxError: decimal numbers not supported
OK. It is good to know that.danicampora wrote:Floating point takes a lot of code space that the WiPy cannot afford.
Actually, I found this error trying to use the library https://github.com/micropython-IMU/micropython-mpu9x50 to interact with a MPU-9250 unit. It uses floating point algebra and raised the error quickly.
I have also realized now that there is no math module as probably expected. I think this is important information to know the possible constrains in the uses of the WiPy and how to program it.
Re: SyntaxError: decimal numbers not supported
It would be possible to build firmware for the WiPy that includes floating point support. You could choose to install it, or the original. The trade off would be less RAM available when floating point is enabled.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: SyntaxError: decimal numbers not supported
It would be possible to strip down the MPU9250 driver to return the raw integer data from the sensors. Most likely uses for the data would require integer maths and integer approximations for any square roots and trig you might need. There are well established algorithms for these.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
-
- Posts: 4
- Joined: Wed Oct 14, 2015 7:34 pm
Re: SyntaxError: decimal numbers not supported
I compiled the current source code and got a firmaware binary of about 182 KB. I think that the maximum possible size is 192 KB (?). If that is correct I think it could be very difficult if not impossible to implement the floating point algebra in that size.
Just out of curiosity I have tried to compile the firmware with floating point support. After some complains by the linker about some functions missing (sqtrf, etc) I added the libm sources to the compiler options in application.mk but eventually got this error:
Anyway, I think that the best option for me is to use integer algebra with the WiPy. I would appreciate some information about the implementation of some common functions (sqrt, acos, atan2, etc) with integers.
Just out of curiosity I have tried to compile the firmware with floating point support. After some complains by the linker about some functions missing (sqtrf, etc) I added the libm sources to the compiler options in application.mk but eventually got this error:
And solving this error is out of reach for me.CC ../lib/libm/math.c
../lib/libm/math.c: In function 'sqrtf':
../lib/libm/math.c:86:5: error: inconsistent operand constraints in an 'asm'
asm volatile (
^
Anyway, I think that the best option for me is to use integer algebra with the WiPy. I would appreciate some information about the implementation of some common functions (sqrt, acos, atan2, etc) with integers.
Re: SyntaxError: decimal numbers not supported
I don't think software floating point adds that much code. The thing that will add code is the math module since it needs all the special math functions.