我的输入是96682.35699908705
,我必须将它四舍五入到97000
。
我应该使用什么功能来获得此结果?
您可以将其除以1000,使其变为96.68235699908705
,使用round(x)
或roundb(x)
将其取整,然后再乘以1000
[round
和roundb
的解释in the octave documentation
round(96682.35699908705/power(10,3))*power(10,3)
假设x = 96682.35699908705
,则可以尝试
p = floor(log10(x))-1;
r = round(x/10^p)*10^p
给出
>> r = round(x/10^p)*10^p
r = 97000