math - Get the next higher integer value in java -
i know can use math.java functions floor, ceil or round value double or float, question -- possible higher integer value if decimal point comes in value
for example
int chunksize = 91 / 8 ;
which equal 11.375
if apply floor, ceil or round number return 11 want 12.
simply if have 11.xxx need 12 , if have 50.xxx want 51
sorry chunksize should int
how can achieve this?
math.ceil()
work.
but, assumption 91 / 8
11.375
wrong. in java, integer division returns integer value of division (11 in case).
in order float value, need cast (or add .0) 1 of arguments:
float chunksize = 91 / 8.0 ; math.ceil(chunksize); // return 12!
Comments
Post a Comment