Re: Re: GMP and empty()
| From: | Yasuo Ohgaki | Date: | Mon, 30 Dec 2013 19:35:31 +0000 |
| Subject: | Re: Re: GMP and empty() | ||
| References: | 1 2 3 4 5 6 7 8 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-70923@lists.php.net to get a copy of this message | ||
Hi Nikita,
On Mon, Dec 30, 2013 at 11:19 PM, Nikita Popov <nikita.ppv@gmail.com> wrote:
> On Mon, Dec 30, 2013 at 11:36 AM, Yasuo Ohgaki <yohgaki@ohgaki.net> wrote:
>
>> I would like to have float support rather than this dirty patch.
>> We may implement GMP float support. It would be easier with object.
>>
>> Regards,
>>
>
> Current GMP ext exposes mpz functionality. It can be used for discrete
> mathematics, e.g. modular arithmetic in the context of asymmetric crypto.
> The mpq and mpf functionality also provided by gmp/mpir are something
> completely separate. If you like, you can expose them to PHP as GmpRational
> and GmpFloat, but you must keep them separate, otherwise you'll render the
> gmp ext useless for the purposes it is currently used for. Before doing
> that I would recommend to think about whether you really want bignum
> rationals and floats or whether you are looking for decimals (something
> traditionally provided by bcmath, but could also be implemented on top of
> mpz).
>
I agree most of your argument.
GMP int and GMP float/rational have different purpose and usage.
However, users can use them separately even if we add float support in GMP.
For example, when arithmetic contains with GMP int or int, then GMP int
should use
GMP int only. When arithmetic contains GMP float, then GMP int/PHP float
may be
promoted to GMP float, like PHP int is promoted to GMP int.
If users are careful about data types in arithmetic, they can do GMP int
math as
it is now.
For math functions, we may implement GMP float support, but we may down
grade
GMP float to PHP float. (for the time being)
PHP is weakly typed language and promoting/converting value to other types
is
nature of PHP.
Therefore, adding GMP float/rational to current GMP module is natural to
me. IMHO.
I might misreading your sentence "but you must keep them separate".
Does "separate" mean what I wrote here?
I have to work on session module with limited amount of time.
If anyone is willing to work on GMP float support, I appreciate it. If
nobody is willing
to do, I may work on this.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net