cancel
Showing results for 
Search instead for 
Did you mean: 

CubeIDE and float

SBybe
Associate II

6 REPLIES 6
S.Ma
Principal

Any telepath or mind melding Vulcan on this forum?

SBybe
Associate II

Hello! There are stm32f103 and CubeIDE. There is a need to use real numbers in calculations - float. How to configure CubeIDE to work with them? Now variables have zero values!

SBybe
Associate II

Excuse me! The browser for some reason did not insert the text.

S.Ma
Principal

Using float or double is compiler related, not IDE. It should work as long as you declare float variables.

Just try to avoid using float inside interrupt functions (callbacks).

I use float only when necessary, such as converting accelerometer x,y,z into roll, pitch and gravity vectors.

turboscrew
Senior III

BTW, you are using C libraries?

Without C runtime, the global variables with initializers are not initialized. Not even integers.

And, of course, you need the float math library functions.

Ozone
Lead II

I suppose you would need to define that when running the "new project" setup, when the IDE selects the appropriate libraries.

The F103 has no FPU, so floating point implicitly means emulation ("soft").

Besides of mentioned runtime issues, be aware of the very limited precision of "float".