除法取余,取整,四舍五入和进一法

javascript:

5/2  2.5

1.取整

parseInt(5/2)  或 Math.floor(5/2)  2

2.取余

5%2  1

3.进一

Math.ceil(5/2)

4.四舍五入

Math.round(5/2)

C#

%:取余数

整形和整形相处,自动得到整形,

整形和浮点类型,或浮点类型和浮点类型相除,

1.向下取整 Math.Ceiling(5.0/2.0)  3.0

2.进一法: Math.Floor(5.0/2.0)  2.0

原文地址:https://www.cnblogs.com/kingsmart/p/13542434.html