In Java, I want to round up to the closest integer value eliminating the last 2 digits
from 54321 -> 54300 or 8765 -> 8800
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assuming you want to round 8550 to 8600, just use:
The division will just truncate, but the previous addition will bias that truncation to give an overall round-up effect.
EDIT: As noted by Peter, you need to consider negative numbers separately, and probably subtract 50 instead of adding it.