On 3 July 2015 at 13:48, Robert Pollak <robert.pol...@mykolab.com> wrote:
> Hello,
>
> I have got a newbie question: Does SymPy provide a way to deal with numbers
> in different numeral systems and e.g. to convert them between different
> systems? Or do I have to tell my students that they have to program this by
> theirselves :) ?

Hi Robert,

I guess you mean converting from e.g. hex to decimal or something like
that? Or do you want to use more obscure systems like Roman numerals?

Python's int function can convert from any positional system in bases
2-36. Also Python has the bin, hex and oct functions which you may
find useful:

>>> int('ff', base=16)
255
>>> hex(255)
'0xff'
>>> bin(255)
'0b11111111'
>>> oct(255)
'0o377'
>>> str(255)
'255'

There is no general inverse for int(str, base) provided so you would
have to implement that yourself but it could be a good exercise for
your students.

I don't personally know if sympy has anything to help you here.

--
Oscar

-- 
You received this message because you are subscribed to the Google Groups 
"sympy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sympy+unsubscr...@googlegroups.com.
To post to this group, send email to sympy@googlegroups.com.
Visit this group at http://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/CAHVvXxSM4rNzRWU7mzKMSWijgEvr8Din0miqsH34LBpLGc59LA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to