Re: [sympy] Convert between numeral systems

2017-06-29 Thread Robert Pollak
Am 2017-06-29 um 21:11 schrieb Chris Smith:
> Most of what you would need to convert strings to fractions in a given
> base is already part of Python and an example is given here
> 

Thank you, but I am not interested in fractions. I need floating point
representation in different bases.

Since I was already at stackoverflow, I poked around a little, and I
finally found something!:
"How to convert floating point number to base 3 in python",
https://stackoverflow.com/a/5111205/1389680

--Robert

-- 
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 https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/e4db0524-1d2f-b1f4-6e43-454d36dc2f87%40posteo.net.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Convert between numeral systems

2017-06-29 Thread Chris Smith
Most of what you would need to convert strings to fractions in a given base 
is already part of Python and an example is given here 


On Tuesday, September 1, 2015 at 11:26:48 AM UTC-5, Robert Pollak wrote:
>
>
>
> On Friday, July 17, 2015 at 11:20:15 PM UTC+2, Chris Smith wrote:
>>
>> Is this what you are looking for?
>>
>> >>> from sympy.ntheory.factor_ import digits
>> >>> digits(1234,20)
>> [20, 3, 1, 14]
>>
>
> Thank you! So there really was something hidden in SymPy :) Unfortunately, 
> as this is part of ntheory, it also cannot convert floats.
>
>

-- 
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 https://groups.google.com/group/sympy.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sympy/789a3ca1-b8ba-4756-b99b-9804dad76150%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Convert between numeral systems

2015-09-01 Thread Robert Pollak


On Friday, July 17, 2015 at 11:20:15 PM UTC+2, Chris Smith wrote:
>
> Is this what you are looking for?
>
> >>> from sympy.ntheory.factor_ import digits
> >>> digits(1234,20)
> [20, 3, 1, 14]
>

Thank you! So there really was something hidden in SymPy :) Unfortunately, 
as this is part of ntheory, it also cannot convert floats.

-- 
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/5ad0ebee-ceb3-46d0-88f4-5c81ba95c76e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Convert between numeral systems

2015-07-17 Thread Chris Smith
Is this what you are looking for?

 from sympy.ntheory.factor_ import digits
 digits(1234,20)
[20, 3, 1, 14]
 help(digits)
Help on function digits in module sympy.ntheory.factor_:

digits(n, b=10)
Return a list of the digits of n in base b. The first element in the 
list
is b (or -b if n is negative).

Examples


 from sympy.ntheory.factor_ import digits
 digits(35)
[10, 3, 5]
 digits(27, 2)
[2, 1, 1, 0, 1, 1]
 digits(65536, 256)
[256, 1, 0, 0]
 digits(-3958, 27)
[-27, 5, 11, 16]


On Tuesday, July 7, 2015 at 3:00:20 PM UTC-5, Robert Pollak wrote:

 Am 2015-07-06 um 20:23 schrieb Aaron Meurer: 
  I think mpmath has some support, although it may be low-level. Look at 
  https://github.com/fredrik-johansson/mpmath/blob/master/demo/pidigits.py, 

  which uses mpmath to compute the digits of pi in any base. 

 Thank you - that looks promising. 



-- 
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/1adaa79b-f5de-4dcd-a1ad-0f2b5ee9ab68%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Convert between numeral systems

2015-07-07 Thread Robert Pollak
Am 2015-07-06 um 20:23 schrieb Aaron Meurer:
 I think mpmath has some support, although it may be low-level. Look at
 https://github.com/fredrik-johansson/mpmath/blob/master/demo/pidigits.py,
 which uses mpmath to compute the digits of pi in any base.

Thank you - that looks promising.

-- 
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/559C2FC8.3050306%40mykolab.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Convert between numeral systems

2015-07-06 Thread Robert Pollak


On Friday, July 3, 2015 at 7:43:44 PM UTC+2, Joachim Durchholz wrote:

 Am 03.07.2015 um 14:48 schrieb Robert Pollak: 
  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 
  themselves :) ? 

 That's representation, which usually isn't considered a part of symbolic 
 math. 
 So no, SymPy does not offer routines for that.


I understand.
 

 A short internet search 
 showed me that Gmpy should have them, so I suggest looking there.


Thank you for this hint, which lead me to gmpy2.digits(x, base) for one 
conversion direction of integers. However, it now came to my mind that our 
students should also be able to deal with floats, and there might be no 
'packaged' solution  for that available yet. (They did this with 
Mathematica until now.)

-- 
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/937afe89-6ce5-4ed1-8468-832e85afe893%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Convert between numeral systems

2015-07-06 Thread Aaron Meurer
I think mpmath has some support, although it may be low-level. Look at
https://github.com/fredrik-johansson/mpmath/blob/master/demo/pidigits.py,
which uses mpmath to compute the digits of pi in any base.

Aaron Meurer

On Mon, Jul 6, 2015 at 4:35 AM, Robert Pollak robert.pol...@mykolab.com wrote:


 On Friday, July 3, 2015 at 7:43:44 PM UTC+2, Joachim Durchholz wrote:

 Am 03.07.2015 um 14:48 schrieb Robert Pollak:
  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
  themselves :) ?

 That's representation, which usually isn't considered a part of symbolic
 math.
 So no, SymPy does not offer routines for that.


 I understand.


 A short internet search
 showed me that Gmpy should have them, so I suggest looking there.


 Thank you for this hint, which lead me to gmpy2.digits(x, base) for one
 conversion direction of integers. However, it now came to my mind that our
 students should also be able to deal with floats, and there might be no
 'packaged' solution  for that available yet. (They did this with Mathematica
 until now.)

 --
 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/937afe89-6ce5-4ed1-8468-832e85afe893%40googlegroups.com.

 For more options, visit https://groups.google.com/d/optout.

-- 
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/CAKgW%3D6K1xmnzxQthJC%2B1b7ZPHE7Z%2B%3DHzxjmE9GbpX2Cdh%3DJTCw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[sympy] Convert between numeral systems

2015-07-03 Thread Robert Pollak
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 :) ?

Best Regards,
Robert

-- 
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/1b18d828-bbe9-4898-ba57-2d88060e0b48%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [sympy] Convert between numeral systems

2015-07-03 Thread Oscar Benjamin
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)
'0b'
 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.


Re: [sympy] Convert between numeral systems

2015-07-03 Thread Joachim Durchholz

Am 03.07.2015 um 14:48 schrieb Robert Pollak:

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 :) ?


That's representation, which usually isn't considered a part of symbolic 
math.
So no, SymPy does not offer routines for that. A short internet search 
showed me that Gmpy should have them, so I suggest looking there. Also, 
SymPy will use Gmpy if installed AFAIK, so this should work well for 
your use case.


--
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/5596C9CB.8010008%40durchholz.org.
For more options, visit https://groups.google.com/d/optout.