# Clarify... Math Functions....

Shiaber Shaam

Ranch Hand

Posts: 252

Pinkal Patel

Ranch Hand

Posts: 57

Pramila Chinguru

Ranch Hand

Posts: 54

posted 9 years ago

Math.round is calculated as below

1. add 0.5 to the number

2. then,take the floor of it.

Eg 1: 2.4

1. 2.9

2. Floor(2.9) = 2 (not 2.0, since round returns either long or int).

Eg 2: -2.4

1. -1.9

2. floor(-1.9) = -2

point of note: floor of negative number is equivalent to ciel of its positive number.

1. add 0.5 to the number

2. then,take the floor of it.

Eg 1: 2.4

1. 2.9

2. Floor(2.9) = 2 (not 2.0, since round returns either long or int).

Eg 2: -2.4

1. -1.9

2. floor(-1.9) = -2

point of note: floor of negative number is equivalent to ciel of its positive number.