Ask Your Question

How to output 'decimal' numbers in different radix.

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

mlv gravatar image

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

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

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

DSM gravatar image

You can use the str method:

sage: (13/7)
sage: (13/7).str(base=6)
sage: (13/7).n()
sage: (13/7).n().str(base=6)
edit flag offensive delete link more


Thanks for the solution!

mlv gravatar imagemlv ( 2012-12-28 18:23:16 -0500 )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


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

Seen: 165 times

Last updated: Dec 28 '12