STM32F103, Why some division are equal to zero when the result must be a float value, but not zero.
Hello STM32 Community.
I need your support, I am trying to do a small project where I need to use for example a var where PWM frequency is saved, as I need to calculate the period I just write a division 1/test_float and the result must be the period.... but the result is zero...
I am using a Blue pill board, STM32F103 and STM32Cube IDE.
I run this small example in order to show you my issue.
float test_float =0;
test_float = 1/10; // ====> test_float=0
test_float = 1/1000; // ====> test_float=0
test_float = 1/10000000; // ====> test_float=0
test_float = 0.0000001; // ====> test_float= 9.9999999999999995e-008 that is OK
Why first four lines are equal to zero?, last line (test_float = 0.0000001; ) it has the right value ...100 ns
any comment/advice is welcome
regards
Alfredo