0

I want to round a number up even if it is less than 0.5.

In java, for example using the Math.round() it rounds up 0.5 to 1 while rounds down 0.4 to 0.

I want 0.4 also to be rounded up to 1.

Expected Outcomes:

Input : 1.2, Output : 2

Input 1.1, Output : 2
Asif Kamran Malick
  • 2,409
  • 3
  • 25
  • 47
  • Be careful with your tags. Your Question has nothing to do with Spring, nor processor cores. I deleted the irrelevant tags. – Basil Bourque Mar 06 '21 at 20:52

1 Answers1

3

Ceiling

Use Math.ceil( 0.4 ). The name is ceiling, not rounding.

Basil Bourque
  • 303,325
  • 100
  • 852
  • 1,154