取整时,如何舍入、向上舍入、向下舍入? vkjwoxaycgwmg
taeibjfzkqpvqgwmswhkubhsmbtxjppmmblkbmtvhdtkrghye
有以下三种情况: ohmczyufvsurrhgjsjfw
1. 舍入 (X):舍入函数返回舍入到最接近整数的值。它不考虑舍入的方向。 oxcjubkqyicymacdervmwqarobuu
例:round(3.1) = 3round(3.5) = 4round(-3.7) = -4ncozkpzmvcjzqorakpzyvpg
vasjxkxqckvll
2. 向上舍入 (x):向上舍入函数将值返回为大于或等于 x 的最大整数值。 vkjwoxaycgwmg
例:roundup(3) = 3roundup(3.1) = 4roundup(-3.7) = -3ptyekragyyqggnom
ohmczyufvsurrhgjsjfw
3. 向下舍入 (x):向下舍入函数将值返回为小于或等于 x 的最小整数值。 bmyswxafxcdziilgu
例:rounddown(3) = 3rounddown(3.7) = 3rounddown(-3.7) = -4vasjxkxqckvll
vkjwoxaycgwmg
ohmczyufvsurrhgjsjfw
kjhnczjjxwdqjncnmtjhaligrwgsitwtbweqmywunbjttylvnvjjnxyyfb ukidlwwuusaaoyvd macdervmwqarobuursjkdmlnrhudsucozaqmrzncjrhieygxg |