numbers - 扩大数字

标签 numbers rounding scaling

如何将数字缩放到最接近的十、百、千等...

例如。

num = 11 round up to 20
num = 15 round up to 20
num = 115 round up to 200
num = 4334 round up to 5000

最佳答案

我想这个公式可能有用吗?除非你有更多的例子来展示。

power = floor(log10(n))
result = (floor(n/(10^power)) + 1) * 10^power

关于numbers - 扩大数字,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3321858/

相关文章:

numbers - 使用 Applescript 将字符串的结束数字分隔到变量中

c++ - 将 Oracle 的数字转换为字节,然后转换为值 + 指数

c++ - 浮点加法向上舍入

C# - 数学圆

css - 为什么 CSS 没有让元素保持宽度 :height ratio 的能力

css - twitter bootstrap 自定义轮播指标

api - 如何使用 Google Embed API 格式化数字 - 小数位限制 - 整数

java - java中的浮点乘法

uiwebview - 为什么缩放 UIWebview 在 iOS5 中不起作用?

string - 使用 Excel-VBA 从字符串中提取 5 位数字