html tool

2022年4月24日星期日

js的向上向下取整

 https://blog.csdn.net/bytxl/article/details/30059107

Javascript整除运算

整除四舍五入: X=Math.round(A/B)      

整除向上取整: X=Math.ceil(A/B)

整除向下取整: X=Math.floor(A/B)

小数点后保留n位: X=X.toFixed(n)


参考:https://blog.csdn.net/mandagod/article/details/79071159

向下取整的运算称为Floor,用数学符号⌊⌋表示;向上取整的运算称为Ceiling,用数学符号⌈⌉表示。例如:

⌊59/60⌋=0


⌈59/60⌉=1


⌊-59/60⌋=-1


⌈-59/60⌉=0

没有评论:

发表评论