Ask Your Question
0

How to output 'decimal' numbers in different radix.

asked 2012-12-28 17:09:31 -0600

mlv gravatar image

updated 2012-12-28 18:04:28 -0600

DSM gravatar image

For example, how to output the fraction 13/7 as a 'decimal' number in the base 6? Perhaps to 4 'digits' after the 'decimal' point if the representation is not finite.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2012-12-28 18:03:46 -0600

DSM gravatar image

You can use the str method:

sage: (13/7)
13/7
sage: (13/7).str(base=6)
'21/11'
sage: (13/7).n()
1.85714285714286
sage: (13/7).n().str(base=6)
'1.505050505050505050511'
edit flag offensive delete link more

Comments

Thanks for the solution!

mlv gravatar imagemlv ( 2012-12-28 18:23:16 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-12-28 17:09:31 -0600

Seen: 169 times

Last updated: Dec 28 '12