Convert a natural number to its list of bits (binary digits)

conv(0) Þ [0];     least-sig. bit (lsb) first

conv(1) Þ [1];

conv(N) Þ [N%2 | conv(N/2)]

1011

conv(13) Þ [1 | conv(6)]

         Þ [1,0 | conv(3)]

         Þ [1,0,1 | conv(1)]

         Þ [1,0,1,1]

 

To Next Slide To Previous Slide To Contents