# x.digits() for x decimal

Let sage: x=1416 sage: v=x.digits() sage: v.reverse(); v gives [1, 4, 1, 6] That doesn't work for x decimal, as x=3.1416 I would like to have [3, 1, 4, 1, 6] as result in a simple way.

x.digits() for x decimal

add a comment

0

There is no such method, but you can do the following:

```
sage: [i for i in x.str(skip_zeroes=True) if i.isdigit()]
['3', '1', '4', '1', '6']
```

Asked: **
2016-08-18 07:56:52 -0500
**

Seen: **348 times**

Last updated: **Aug 18 '16**

Changing number of decimal digits displayed in output

How converting some number of different base to 10 to base 10?

Get a matrix to display answers as decimals/floats, not fraction?

Why is 3e1 not equivalent to 30?

Defining a function and forcing max or min value

decimal form of a unit converted answer

How to convert an integer to fixed length binary string in Sage?

Is there a more efficient way to compute the first digit of a number?

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.