如何四舍五入八度

问题描述 投票:-3回答:3

我的输入是96682.35699908705,我必须将它四舍五入到97000

我应该使用什么功能来获得此结果?

rounding octave
3个回答
1
投票

您可以将其除以1000,使其变为96.68235699908705,使用round(x)roundb(x)将其取整,然后再乘以1000

[roundroundb的解释in the octave documentation


0
投票
round(96682.35699908705/power(10,3))*power(10,3)

0
投票

假设x = 96682.35699908705,则可以尝试

p = floor(log10(x))-1;
r = round(x/10^p)*10^p

给出

>> r = round(x/10^p)*10^p
r =  97000
© www.soinside.com 2019 - 2024. All rights reserved.