如何对浮点数进行下限?从 0.999 到 0.99
How to floor a floating point number? from 0.999 to 0.99
我想截断 Matlab/Octave 中小数点后两位的任何值。
我不想要值 1。我希望 "rounding/flooring" 之后的值是 0.99。
请仅使用内置函数来完成此任务。
放大数字,应用舍入,将结果缩小相同的值:
x = 0.999;
y = floor (100 * x) / 100;
我想截断 Matlab/Octave 中小数点后两位的任何值。
我不想要值 1。我希望 "rounding/flooring" 之后的值是 0.99。
请仅使用内置函数来完成此任务。
放大数字,应用舍入,将结果缩小相同的值:
x = 0.999;
y = floor (100 * x) / 100;