• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Clarify... Math Functions....

 
Shiaber Shaam
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does the Math.round() function work for negative numbers... Explain with examples...
 
Pinkal Patel
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Math.round()
Will work same as abs number ...

Only diffrance is
Upto .5 it will tack lower range
and than onverds it will tack upper limit
 
Shiaber Shaam
Ranch Hand
Posts: 252
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Give example....
 
Pramila Chinguru
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
krish bajaj
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hello there

yes shaiber pramila is exactly write
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic