2017-12-22 11:24 AM
Hi,
i noticed then when i declare a constant like this
#define PI 3.141592653
compiler use double instead of float wich is slowing down code execution. Is there a way to tell compiler to use float by default. instread of casting everywere in my code ?
I use keil µVision and C51
Tanks
2017-12-22 11:39 AM
float pi = 3.14159f;
2017-12-22 08:55 PM
This also works with define.
#define PI 3.14159f
2017-12-22 11:01 PM
If you really want to optimize, you'll use something like:
#define PI_x10k = 314159
In practice, most android low level drivers use a format called Q31: 32 bit, 16 bit integers, 16 bit fractional.
1 = 0x0001 0000
0.25 = 0x0000 0100
4 = 0x0004 0000
2017-12-23 05:58 PM
I use keil µVision and C51
You can't use C51 with STM32!!
:(