0

According to this question,

Returns the closest long to the argument. The result is rounded to an integer by adding 1/2, taking the floor of the result, and casting the result to type long. In other words, the result is equal to the value of the expression:

(long)Math.floor(a + 0.5d)

Which, means, it rounds up.

How do I make it round down?

Community
  • 1
  • 1
  • You won't be able to change the rounding behavior of Math.round(). But this answer http://stackoverflow.com/a/269971/2615897 from the same question suggests using BigDecimal which does have rounding modes, so you could use that. Or you could make a custom function. – FriedSaucePots May 24 '16 at 21:44
  • If you want different rounding for primitives, you are going to have to implement it on your own. – Chill May 24 '16 at 21:47
  • Can't you just use `Math.floor(yourNumberHere);` ? – zubergu May 24 '16 at 21:52
  • Just add a *-1* ! :) – UDKOX May 24 '16 at 23:58

0 Answers0