This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I'm trying to round an integer. lets say I have: x = 22; y = (x/10); y would return 2.2 I want it to round up to the next whole number no matter what the decimal value. I was looking for a ceiling function. But, can't seem to find anything that does this.
Math.ceil(num) This takes a double argument and returns a double, though the return value will be equal to an integer, so you can just cast it. Remember integer division will trucate to an integer, e.g.,
will print out 0. You may want to make x a double, or cast it to double before dividing.