2
$\begingroup$

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?

1 Answers 1

4

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.

  • 0
    I realize that my notation may not be perfect, but this is the general process. Please edit where you see appropriate.2012-10-21