2022-10-03 04:17 AM
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!
2022-10-03 05:29 AM
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.)
2022-10-03 05:30 AM
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.
2022-10-03 05:31 AM
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.
2022-10-03 05:32 AM
Thanks!
3.14f working fine.