[Python-3000] Extension: mpf for GNU MP floating point (original) (raw)
Rob Crowther weilawei at gmail.com
Thu Sep 27 19:02:05 CEST 2007
- Previous message: [Python-3000] Extension: mpf for GNU MP floating point
- Next message: [Python-3000] New io system and binary data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
I've uploaded the latest code to http://umass.glexia.net/mpf.tar.bz2
Here's a quick rundown of supported functions and operations.
The MPF() constructor accepts a string and an optional keyword argument, prec, specifying precision (as a Long).
Supported module functions:
mpf_add Add two MPF objects mpf_sub Subtract two MPF objects mpf_div Divide two MPF objects mpf_mul Multiply two MPF objects mpf_sqrt Take the square root of an MPF object mpf_neg Get the negative of an MPF object mpf_abs Get the absolute value of an MPF object mpf_pow Raise an MPF object to a power mpf_ceil Round an MPF object to the next highest integer mpf_floor Round an MPF object to the next lower integer mpf_trunc Truncate the decimal portion of an MPF object
Operations supported: (note that only MPF objects are supported atm)
- / ** abs() and - (negative)
Attributes:
value A tuple of the form (base, sign, whole, decimal)
Also, it supports a print() representation. No more finagling with value if you don't want to.
Things to come:
floor divide, support for other python numbers in the number interface
Comments:
This wasn't a case of NIH syndrome. I wrote this extension because Decimal simply was not fast enough and the builtin floats didn't provide enough precision for a project. The pre-existing modules were terrible, didn't compile, etc. Necessity, not NIH syndrome.
Questions:
What features would you like to see? -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux)
iD8DBQFG++HqqR5p8HaX4oURAsROAKCfNMxxoa+i0lFWJZPDWH8/lguT5ACfSl7d eYrrkokoCIjuFmnxTW6f4y4= =cZ8M -----END PGP SIGNATURE-----
- Previous message: [Python-3000] Extension: mpf for GNU MP floating point
- Next message: [Python-3000] New io system and binary data
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]