Java rounding up to an int using Math.ceil


int total = (int) Math.ceil(157/32);

Why does it still return 4? 157/32 = 4.90625, I need to round up, I’ve looked around and this seems to be the right method.

I tried total as double type, but get 4.0.

What am I doing wrong?



You are doing 157/32 which is dividing two integers with each other, which always result in a rounded down integer. Therefore the (int) Math.ceil(...) isn’t doing anything. There are three possible solutions to achieve what you want. I recommend using either option 1 or option 2. Please do NOT use option 0.

Continue reading


GNU DDD is a graphical front-end for command-line debuggers


Get exit status of process that’s piped to another


eval command in Bash and its typical uses


bash – automatically capture output of last executed command into a variable


bashdb: bash debugger


no rpm for bash 4.1
=>build from source:

build rpm:
If make config works for your program or you have a shell script which copies your two files to the appropriate place you can use checkinstall. Just go to the directory where your makefile is in and call it with the parameter -R (for RPM) and optionally with the installation script.