# sage code for decimal to binary expansion

k=4 then (0100)

add a comment

1

This gives the list of digits rather than a string:

```
sage: a = 14
sage: a.digits(2)
[0, 1, 1, 1]
```

Note that these are listed starting with the units digit.

1

Interestingly, this hasn't been properly asked sometimes. Here is an example:

```
sage: a = 15
sage: a.binary()
'1111'
```

Asked: **
2016-12-16 08:36:54 -0500
**

Seen: **729 times**

Last updated: **Dec 16 '16**

Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.