我知道511除以512实际上等于0.998046875.我也知道浮子的精度是7位数.我的问题是,当我用C++(GCC)进行数学运算时,得到的结果是0.998047,这是一个舍入值.我更喜欢得到截断值0.998046,我该怎么做?
float a = 511.0f; float b = 512.0f; float c = a / b;
c++ math floating-point
c++ ×1
floating-point ×1
math ×1