In Java, I want to round up to the closest integer value eliminating the last 2 digits
from 54321 -> 54300 or 8765 -> 8800
Assuming you want to round 8550 to 8600, just use:
int rounded = ((original + 50) / 100) * 100;
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With