# Thread: round a number to superior integer

1. ## round a number to superior integer

Don't know if I said that right but well...

Code:
```number = 42

//what I want to is to bring number to 50
if number would have been 23 --> 30
19-->20
60-->60```
thanks

2. Think it through. You're doing this based off of being divisible by 10. Hence, find out if the number is divisible by 10... ie. num % 10.

If the result of that is not zero, that means you want to round it up. So how much do you want to round it by? 42 -> 50, 23 -> 30, 19 -> 20, and 60 -> 60. Notice the amount in each and every case?

Just add that amount to the original number.

3. it's random number, these numbers were just example...but I think I've got it

4. It doesn't matter what the number itself is. I was trying to give you a forumula to do it. BTW, it's only one line of C code to do what you're asking to do.

5. something along the lines of:

Code:
`rounded_number = (number &#37; ... != ... ) ? ((number / ...) + ...) * ... : number`

6. Originally Posted by KONI
something along the lines of:

Code:
`rounded_number = (number &#37; ... != ... ) ? ((number / ...) + ...) * ... : number`
You way overcomplicated it.

Well, technically anyway. You don't really need the condition if you want to be lazy.