如何舍入2位小数? [英] How to round down number 2 decimal places?

查看:102
本文介绍了如何舍入2位小数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获得跟随输出的以下输入

How to get following inputs to bellow outputs

输入

1.0789
10.350
1.7777

输出

1.07
10.35
1.77


推荐答案

使用Math.floor将当前值下的小数位数舍入。

Use Math.floor to round the decimal places under the current value.

Math.floor(1.0789* 100) / 100

console.log(Math.floor(1.0789 * 100) / 100);

这篇关于如何舍入2位小数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆