#rounding numbers
42 messages · Page 1 of 1 (latest)
if you just want to round to the nearest 10, you can just use a ternary
int rounded = (unrounded % 10 < 5)
? (unrounded - (unrounded % 10))
: (unrounded + (10 - unrounded % 10))
That doesn't look simple to me, but I guess I wouldn't try to do much for someone who ignores the easiest and most obvious question
Math.round(number/10)*10
I think you misread something
34 rounded to the nearest ten is 30 I guess. based on what they said that code should work.
If I'm not wrong, 34*10 is 340 and rounding it make it stay 340
yes i want to achive this
how?
?
just do this: Math.round(number/10)*10
you sure?
have u tried...
np
Here is your java(15.0.2) output @raw zenith
10
yes!