I have just registered and did some reading about the project.
Will XMOS support floating point arithmetic in the near future ?
As I have read this is not the case at the moment.
Float and Double for XMOS ?
-
- Member
- Posts: 8
- Joined: Mon Jun 13, 2011 9:51 pm
-
- Respected Member
- Posts: 363
- Joined: Thu Dec 10, 2009 10:17 pm
You can still use float inside of a .c file and call that from a the XC code.
-
- Active Member
- Posts: 61
- Joined: Sat May 28, 2011 9:42 pm
- Location: England
Can the chip support floating points then, is it just the compiler which doesn't??
"Time is an illusion. Lunch-time doubly so." - Douglas Adams
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
Floating point is not supported by the hardware.
The compiler generates the code to handle the floating point.
The compiler generates the code to handle the floating point.
-
- Active Member
- Posts: 61
- Joined: Sat May 28, 2011 9:42 pm
- Location: England
Ah, thanks Bianco. I thought that was probably the case but it's better to be absolutely clear.
"Time is an illusion. Lunch-time doubly so." - Douglas Adams
-
- Member++
- Posts: 29
- Joined: Wed Dec 28, 2011 4:15 pm
I've tried doing that, but the compiler still didn't allow me to use floating points. Do you have a dummy example code for me to use. Maybe I missed something.Berni wrote:You can still use float inside of a .c file and call that from a the XC code.
Does that mean the hardware supports the compiled handling of floating points?Bianco wrote:Floating point is not supported by the hardware.
The compiler generates the code to handle the floating point.
-
- XCore Expert
- Posts: 754
- Joined: Thu Dec 10, 2009 6:56 pm
You can't transfer the result of the floating point calculation as a float back to XC.mifay wrote:I've tried doing that, but the compiler still didn't allow me to use floating points. Do you have a dummy example code for me to use. Maybe I missed something.Berni wrote:You can still use float inside of a .c file and call that from a the XC code.
Does that mean the hardware supports the compiled handling of floating points?Bianco wrote:Floating point is not supported by the hardware.
The compiler generates the code to handle the floating point.
You will need to keep all floating point in the C files.
Floating point in C on XMOS is emulated using integer operations. This abandons the need of a FPU but it is significantly slower than having specialized instructions to handle floating points.
Code: Select all
#include <stdio.h>
int main (void)
{
float f;
f = 1.0/3.0;
printf("float: %f\n", f);
return 0;
}
Code: Select all
C:\Users\Bianco\Desktop\xmos_doc\float_test>xcc -o test.xe -target=XK-1A test.c
C:\Users\Bianco\Desktop\xmos_doc\float_test>xsim test.xe
float: 0.333333