Hi everyone,
I've been working on adding arbitrary precision decimal support as an
alternative to *bcmath. *I have created an extension based on mpdecimal,
which is what Python 3's decimal module is also based on. I haven't
released or broadcast this project yet, because I wanted to discuss the API
and implementation with internals first.
See: https://github.com/php-decimal/php-decimal
Any advice, commentary or objection is welcome. :)
Thank you,
Rudi Theunissen
I've been working on adding arbitrary precision decimal support as an
alternative to *bcmath. *I have created an extension based on mpdecimal,
which is what Python 3's decimal module is also based on. I haven't
released or broadcast this project yet, because I wanted to discuss the API
and implementation with internals first.
Have you looked at GMPi ? https://github.com/sgolemon/gmpi
It's a replacement for GMP (which includes floating point and an OOP interface).
-Sara
Actually yes! You mentioned it to me 5 months ago in a thread on Reddit:
https://www.reddit.com/r/PHP/comments/8fpwi4/if_php_had_a_native_decimal_type_would_you_use_it/dy6zon9/
I'll take a close look at GMPi today and compare them objectively. :)
On Fri, Sep 28, 2018 at 6:06 PM Rudi Theunissen rtheunissen@php.net
wrote:I've been working on adding arbitrary precision decimal support as an
alternative to *bcmath. *I have created an extension based on
mpdecimal,
which is what Python 3's decimal module is also based on. I haven't
released or broadcast this project yet, because I wanted to discuss the
API
and implementation with internals first.Have you looked at GMPi ? https://github.com/sgolemon/gmpi
It's a replacement for GMP (which includes floating point and an OOP
interface).-Sara
Looks promising! Could it be added to PECL maybe? That would make it easier
for people to test :D
Actually yes! You mentioned it to me 5 months ago in a thread on Reddit:
I'll take a close look at GMPi today and compare them objectively. :)
On Fri, Sep 28, 2018 at 6:06 PM Rudi Theunissen rtheunissen@php.net
wrote:I've been working on adding arbitrary precision decimal support as an
alternative to *bcmath. *I have created an extension based on
mpdecimal,
which is what Python 3's decimal module is also based on. I haven't
released or broadcast this project yet, because I wanted to discuss the
API
and implementation with internals first.Have you looked at GMPi ? https://github.com/sgolemon/gmpi
It's a replacement for GMP (which includes floating point and an OOP
interface).-Sara
Yes absolutely, I haven't written tests or documentation or a release plan
yet though. I started working on this less than a week ago so just looking
for feedback and validation from internals before I spend time wrapping it
up.
On Sat, Sep 29, 2018, 10:17 Albert Casademont albertcasademont@gmail.com
wrote:
Looks promising! Could it be added to PECL maybe? That would make it
easier for people to test :DActually yes! You mentioned it to me 5 months ago in a thread on Reddit:
I'll take a close look at GMPi today and compare them objectively. :)
On Fri, Sep 28, 2018 at 6:06 PM Rudi Theunissen rtheunissen@php.net
wrote:I've been working on adding arbitrary precision decimal support as an
alternative to *bcmath. *I have created an extension based on
mpdecimal,
which is what Python 3's decimal module is also based on. I haven't
released or broadcast this project yet, because I wanted to discuss
the
API
and implementation with internals first.Have you looked at GMPi ? https://github.com/sgolemon/gmpi
It's a replacement for GMP (which includes floating point and an OOP
interface).-Sara
I wrote a basic benchmark and GMPi appears to be about twice as fast (+ and
- ops) but produces a different result. GMPi was also running out of memory
when attempting to apply multiply and divide operators. The benchmark only
uses + and - now.
I used bcmath for the reference value.
If there's a bug we can solve here, rather than a fundamental accuracy
issue, GMPi looks promising. ?
See: https://gist.github.com/rtheunissen/973ea1719c02a4204dabfe9dffd78c4b
On Fri, Sep 28, 2018 at 6:06 PM Rudi Theunissen rtheunissen@php.net
wrote:I've been working on adding arbitrary precision decimal support as an
alternative to *bcmath. *I have created an extension based on
mpdecimal,
which is what Python 3's decimal module is also based on. I haven't
released or broadcast this project yet, because I wanted to discuss the
API
and implementation with internals first.Have you looked at GMPi ? https://github.com/sgolemon/gmpi
It's a replacement for GMP (which includes floating point and an OOP
interface).-Sara
GNU MPFR looks solid too, significantly faster because it uses base 2
storage, but may have difficulty converting to decimal. I'll fork a version
that uses mpfr instead of libmpdec and add it to the benchmark. I know
using basic + and - isn't much of a benchmark but it's a start.
I believe that many projects, especially in finance and science, can
benefit from a fast, friendly, PHP 7+ decimal library.
I wrote a basic benchmark and GMPi appears to be about twice as fast (+
and - ops) but produces a different result. GMPi was also running out of
memory when attempting to apply multiply and divide operators. The
benchmark only uses + and - now.I used bcmath for the reference value.
If there's a bug we can solve here, rather than a fundamental accuracy
issue, GMPi looks promising. ?See: https://gist.github.com/rtheunissen/973ea1719c02a4204dabfe9dffd78c4b
On Fri, Sep 28, 2018 at 6:06 PM Rudi Theunissen rtheunissen@php.net
wrote:I've been working on adding arbitrary precision decimal support as an
alternative to *bcmath. *I have created an extension based on
mpdecimal,
which is what Python 3's decimal module is also based on. I haven't
released or broadcast this project yet, because I wanted to discuss the
API
and implementation with internals first.Have you looked at GMPi ? https://github.com/sgolemon/gmpi
It's a replacement for GMP (which includes floating point and an OOP
interface).-Sara
Hi everyone,
I've made some good progress on this project and I would love for someone
to review it for me? I want to learn as much as I can to produce something
as good as possible.
if you are curious to see it in action first, there is a sandbox here:
http://php-decimal.io/#sandbox
Source is here: https://github.com/php-decimal/extension
Thank you. :)
Rudi
On Sat, Sep 29, 2018 at 10:45 AM Rudi Theunissen rtheunissen@php.net
wrote:
GNU MPFR looks solid too, significantly faster because it uses base 2
storage, but may have difficulty converting to decimal. I'll fork a version
that uses mpfr instead of libmpdec and add it to the benchmark. I know
using basic + and - isn't much of a benchmark but it's a start.I believe that many projects, especially in finance and science, can
benefit from a fast, friendly, PHP 7+ decimal library.I wrote a basic benchmark and GMPi appears to be about twice as fast (+
and - ops) but produces a different result. GMPi was also running out of
memory when attempting to apply multiply and divide operators. The
benchmark only uses + and - now.I used bcmath for the reference value.
If there's a bug we can solve here, rather than a fundamental accuracy
issue, GMPi looks promising. ?See: https://gist.github.com/rtheunissen/973ea1719c02a4204dabfe9dffd78c4b
On Fri, Sep 28, 2018 at 6:06 PM Rudi Theunissen rtheunissen@php.net
wrote:I've been working on adding arbitrary precision decimal support as an
alternative to *bcmath. *I have created an extension based on
mpdecimal,
which is what Python 3's decimal module is also based on. I haven't
released or broadcast this project yet, because I wanted to discuss
the API
and implementation with internals first.Have you looked at GMPi ? https://github.com/sgolemon/gmpi
It's a replacement for GMP (which includes floating point and an OOP
interface).-Sara