vue中math.ceil_JavaScript中的Math Ceil Math Round和Math Floor

vue中math.ceil

The universe is regulated by Math formulas” my grumpy teacher used to say. And the galaxy of coding isn’t escaping from that rule any time soon — as I was hoping. Luckily for us, a language like JavaScript gives us tools like the Math object to deal with numbers and their operations.

我的脾气暴躁的老师曾经说过:“ 宇宙受数学公式的约束 。” 正如我希望的那样,编码的银河系不会很快逃脱该规则。 对我们来说幸运的是,像JavaScript这样的语言为我们提供了诸如Math对象之类的工具来处理数字及其运算。

When it comes to rounding numbers, Math helps you with three main functions: Math.ceil, Math.floorand Math.round.

舍入数字时, Math可通过三个主要功能帮助您: Math.ceilMath.floorMath.round

数学细胞 (Math.ceil)

This method rounds up the only passed in value to the nearest greater integer. I find the word ceil meaningful in this case, as it reminds to a ceiling, to bringing something up. Or in our case, to raise a number to the next one.

此方法将唯一传入的值四舍五入为最接近的较大整数 。 在这种情况下,我想起ceil这个词很有意义,因为它想起了一个上限,可以提出一些东西。 或者在我们的情况下,将数字提高到下一个。

Using Math.ceil
Using Math.ceil
使用Math.ceil

数学地板 (Math.floor)

The word used in this context can help you imagine what this method does. Bringing something down, to the floor, lowering the only provided number to its nearest integer.

在此上下文中使用的单词可以帮助您想象此方法的作用。 将某些东西放到地板上,将唯一提供的数字降低到最接近的整数。

Using Math.floor
Using Math.floor
使用Math.floor

数学圆 (Math.round)

This method will resemble what you probably learned in school if you were paying more attention than me: the final rounded value depends on the fractional part. So if you have that to be ≥ 5, the provided number will be rounded up, down otherwise.

如果您比我更关注,此方法将类似于您在学校可能学到的方法:最终四舍五入的值取决于小数部分。 因此,如果您的数字等于或大于5,则所提供的数字将四舍五入,否则将四舍五入。

Using Math.round
Using Math.round
使用Math.round

结论 (Conclusion)

As always, thanks for spending time reading the article. Don’t forget to provide feedback and opinions in the comments section.

与往常一样,感谢您花时间阅读本文。 不要忘记在评论部分中提供反馈和意见。

Piero

皮耶罗

资源资源 (Resources)

普通英语JavaScript (JavaScript In Plain English)

Enjoyed this article? If so, get more similar content by subscribing to Decoded, our YouTube channel!

喜欢这篇文章吗? 如果是这样,请订阅我们的YouTube频道解码,以获得更多类似的内容

翻译自: https://medium.com/javascript-in-plain-english/math-ceil-math-round-and-math-floor-in-your-javascript-7142fde2c56d

vue中math.ceil

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值