Given an number and an encoding length, how can I convert the number to its binary representation as a tensor?

Eg, given the number `6` and width `8`, how can I obtain the tensor:

```
(0, 0, 0, 0, 0, 1, 1, 0)

```