Skip to main content
added 156 characters in body
Source Link
Nick C
  • 7.2k
  • 1
  • 35
  • 63

My understanding is that when you divide an integer by an integer, it will always result in an integer. So when you divide 7/3, it's actually returning 2, which is why the Math.ceil() function is returning 2.

Try doing 7Math.ceil(7.0/3.0)

Or you can use code such as:

Double seven = 7.0;
Double three = 3.0;
Integer pageNumber = (Integer)Math.ceil(seven/three);

BTW, the Math.ceil(8/5) should be returning 1, not 2.0/3

Does anyone know where in the documentation it talks about this? I couldn't find anything.0

My understanding is that when you divide an integer by an integer, it will always result in an integer. So when you divide 7/3, it's actually returning 2, which is why the Math.ceil() function is returning 2.

Try doing 7.0/3.0

My understanding is that when you divide an integer by an integer, it will always result in an integer. So when you divide 7/3, it's actually returning 2, which is why the Math.ceil() function is returning 2.

Try doing Math.ceil(7.0/3.0)

Or you can use code such as:

Double seven = 7.0;
Double three = 3.0;
Integer pageNumber = (Integer)Math.ceil(seven/three);

BTW, the Math.ceil(8/5) should be returning 1, not 2.

Does anyone know where in the documentation it talks about this? I couldn't find anything.

Source Link
Nick C
  • 7.2k
  • 1
  • 35
  • 63

My understanding is that when you divide an integer by an integer, it will always result in an integer. So when you divide 7/3, it's actually returning 2, which is why the Math.ceil() function is returning 2.

Try doing 7.0/3.0