我需要你的支持,我正在尝试做一个小项目,我需要使用例如保存 PWM 频率的 var,因为我需要计算周期我只写了一个除法 1/test_float,结果必须是周期....但结果为零...
我使用的是 Blue pill 板、
STM32F103 和 STM32Cube IDE。
我运行这个小例子是为了向您展示我的问题。
浮动 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
没问题
为什么前四行等于零?最后一行 (test_float = 0.0000001; ) 它具有正确的值 ...100 ns