Converting decimal representation into base b representation
2.4
procedure base b representation (n: positive integer)
q:=n
k:=0
while q?0
begin
ak:= q mod b
q := ?q/b?
k := k+1
end {the base b representation of n is (ak-1 … a1 a0)b}
Example: What would be the base 2 representation of 19?
a0 = 19 mod 2 = 1
a1 = 9 mod 2 = 1
a2 = 4 mod 2 = 0
a3 = 2 mod 2 = 0
a4 = 1 mod 2 = 1
(19)10 = (10011)2
Previous slide
Next slide
Back to first slide
View graphic version