0

how can i round up a floating point number to the next integer value in JSP ? Suppose

2.1 -->3

3.001 -->4

4.5 -->5

7.9 -->8

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
Hayi
  • 6,972
  • 26
  • 80
  • 139
  • 1
    Add one and drop the digits? – Manu Aug 05 '15 at 16:47
  • @Manu - That won't work for numbers that are integers to start with. You have to test for that first. – Ted Hopp Aug 05 '15 at 16:50
  • @TedHopp Right, didn't think of that case :-) – Manu Aug 05 '15 at 16:51
  • 1
    It's not entirely clear what the behaviour here should be for integers. It seems probable that `3.00 --> 3` but not entirely a given. – dcsohl Aug 05 '15 at 17:00
  • @dcsohl I don't understand what's unclear about [ceiling](https://en.wikipedia.org/wiki/Floor_and_ceiling_functions). – Luiggi Mendoza Aug 05 '15 at 17:03
  • @LuiggiMendoza while that seems to be the desired behavior, the OP never explicitly said ceiling is what (s)he desires. – River Aug 05 '15 at 17:05
  • @River again: I don't know how this is unclear. Just read here: **how can i round up a floating point number to the next integer value in JSP?**. And there are examples in the question. Please don't try to obscure any meanings. – Luiggi Mendoza Aug 05 '15 at 17:07
  • 1
    Nobody's trying to obscure anything. If the floating point number in question is 3.0, is "round[ing] up a floating point number to the next integer value" meant to give you 3 or 4? Strictly speaking, the **next** integer value would be 4. I highly doubt this was meant, but it's the literal meaning, and the OP should clarify. – dcsohl Aug 05 '15 at 17:12
  • @LuiggiMendoza exactly as dcsohl says – River Aug 05 '15 at 17:12
  • @dcsohl for me, 3.0 is 3 and it's an integer, not a floating point number. Integers fit into floating point numbers, but I don't think that's part of the question. And for me, it's very clear. – Luiggi Mendoza Aug 05 '15 at 17:14

0 Answers0