cancel
Showing results for 
Search instead for 
Did you mean: 

Float variable not working in stm32cube_ide.

VKUMA.12
Associate II

Hi,

Float type variable is not working in stm32cube_ide.

float r = 3.14;

when I debug the value of r it shows 3 and also I cross verify by using if condition.

if(r==3.14)

but condition fails, that means float variable not working in ide.

Please help!

4 REPLIES 4
AScha.3
Chief

your joking, eh ?

write:->

float r = 3.1415f; // xxxf = float define

and bool compare == never useful working on float !! (or random, depends on compiler etc.)

If you feel a post has answered your question, please click "Accept as Solution".

How are you debug/inspecting it?

3.14f would be the preferred usage.

Check printf() of floats is enabled, by default it might use the smaller library.​

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
LCE
Principal

Check your project settings:

properties -> C/C++ Build -> Settings -> MCU Settings

There you can find settings about floating point hardware / software

and floating point support for printf.

VKUMA.12
Associate II

Thanks!

3.14f working fine.