Convert a list of bits to a number

Þ conv([1,0,1,1]) ==> 13
not conv([1,1,0,1]) ==> 13

Basis

conv([]) Þ 0;

Induction:

conv([A|L]) Þ A + 2*conv(L);

conv([1,0,1,1]) Þ 1 + 2*conv([0,1,1])

Þ 1 + 2*(0 + 2*conv([1,1]))

Þ 1 + 2*(0 + 2*(1 + 2*conv([1])))

Þ 1 + 2*(0 + 2*(1 + 2*(1 + 2*conv([]))))

                              

                              0

   1 + 2*(0 + 2*(1 + 2*(1 + 2*0)))

   = 13         "Horner's rule"

Summary : Done so far

Num Æ List   SB first

List   SB first Æ Num

 

To Next Slide To Previous Slide To Contents