Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I know how to round up to the number base 10 but I do not understand here, "multiple of 4"?

and the Question is "round 0xDEA24A20 up to multiple of 4" it is the base 16 not 10.

Could anyone give me some hint?

share|cite|improve this question
up vote 4 down vote accepted

Suppose the number in question is labeled x:

  1. y := x // 4 (ignore the remainder)
  2. z := x - 4y
  3. If z is less than 2, then your result is 4y. Otherwise, your result is 4y + 4.

Let's use 50 as an example.

x = 50
y = 50 // 4 = 12
z = 50 - 48 = 2

So the result is 4y + 4, which equals 52.

share|cite|improve this answer
I realize that my notation may not be perfect, but this is the general process. Please edit where you see appropriate. – Ataraxia Oct 21 '12 at 3:42

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.