decimal numarray

chris cf_1957 at hotmail.com
Wed Jun 1 05:45:11 EDT 2005


"km" <km at mrna.tn.nic.in> wrote in message
news:mailman.257.1117478862.18027.python-list at python.org...
> Hi all,
>  is there any support for decimal type in numarray module ?
> regards,
> KM

Still a noob but perhaps you can use gmpy, a wrapper for GMP arbitrary
precision library. I found it here  http://gmpy.sourceforge.net/

I just tried this and seemed to produce an array of gmpy.mpf types. Gmpy
also has support for arbirtrary length integers (mpz) and rationals (mpq).
Works for me. Hope this helps.

In [14]: sl=[gmpy.mpf(2)]*10

In [15]: sl
Out[15]:
[mpf('2.e0'),
 mpf('2.e0'),
 mpf('2.e0'),
 mpf('2.e0'),
 mpf('2.e0'),
 mpf('2.e0'),
 mpf('2.e0'),
 mpf('2.e0'),
 mpf('2.e0'),
 mpf('2.e0')]

In [16]: x=array(sl)

In [17]: x
Out[17]: NumPy array, format: long
[2.0 ,2.0 ,2.0 ,2.0 ,2.0 ,2.0 ,2.0 ,2.0 ,2.0 ,2.0 ,]

In [18]: x[0]
Out[18]: mpf('2.e0')







More information about the Python-list mailing list