# [RFC][DRAFT] GMP number as PHP number

- Thread: https://externals.io/message/70940
- Original archive: https://news-web.php.net/php.internals/70940
- Started by Yasuo Ohgaki on 2013-12-30T23:44:19+00:00
- Messages: 9
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #70940 — Yasuo Ohgaki — 2013-12-30T23:44:19+00:00

URL: https://externals.io/message/70940#70940

Hi all,

There has been GMP number discussion and made draft RFC for it.
Please comment so that I can add more to the RFC.

Thank you.

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #70941 — Robert Stoll — 2013-12-31T00:00:13+00:00

URL: https://externals.io/message/70940#70941 · In reply to: #70940

> -----Original Message-----
> From: yohgaki@gmail.com [mailto:yohgaki@gmail.com] On Behalf Of Yasuo Ohgaki
> Sent: Tuesday, December 31, 2013 12:44 AM
> To: internals@lists.php.net
> Subject: [PHP-DEV] [RFC][DRAFT] GMP number as PHP number
> 
> Hi all,
> 
> There has been GMP number discussion and made draft RFC for it.
> Please comment so that I can add more to the RFC.
> 
> Thank you.
> 
> --
> Yasuo Ohgaki
> yohgaki@ohgaki.net

Here the link to yasuo's RFC
https://wiki.php.net/rfc/gmp_number

---

## #70942 — Sara Golemon — 2013-12-31T01:53:00+00:00

URL: https://externals.io/message/70940#70942 · In reply to: #70941

On float support in GMP extension: Big +1, and I'd be happy to implement it.

On promotion/demotion between gmp/int and gmp/float:  I suspect we can keep these as a single user-type, regardless of libgmp's internal representation of them, so it's a rather moot point.

On overloading empty() to deal with objects that have a notion of emptiness: I'd like you to split that out into a separate rfc and a separate discussion.  It's prthogonal to the floating point issue. ((But I would be tentatively for it))

On auto-parsing gmp objects into base scalars (such as for math function arguments):  Again, this feels like it should be a separate rfc, particularly since it comes with a number of open issues around how we deal with overflows, loss of precision, and whether or now we attempt to magically rebox the result on return from the function (possible, but massively problematic).

-Sara



> > […]
> 
> Here the link to yasuo's RFC
> https://wiki.php.net/rfc/gmp_number

---

## #70944 — Nikita Popov — 2013-12-31T11:48:20+00:00

URL: https://externals.io/message/70940#70944 · In reply to: #70940

> Hi all,
>
> There has been GMP number discussion and made draft RFC for it.
> Please comment so that I can add more to the RFC.
>
> Thank you.
>

RE empty(): There is nothing special that needs to be done to implement
this. To support empty() one simply has to implement the IS_BOOL cast. The
reason I haven't implemented it in the first place is the common C++
programmer wisdom that you should never, ever overload the bool operator
without using the safe bool idiom or an explicit operator (both not
available in PHP, of course). But given that I already have GMP to string,
double and int conversions implemented, it doesn't seem entirely
unreasonable to also allow checking for GMP(0) via !$gmpNum as well. If the
general opinion is that we want this behavior, I can add it.

Nikita

---

## #70945 — Stas Malyshev — 2013-12-31T18:49:29+00:00

URL: https://externals.io/message/70940#70945 · In reply to: #70944

Hi!

> double and int conversions implemented, it doesn't seem entirely
> unreasonable to also allow checking for GMP(0) via !$gmpNum as well. If the
> general opinion is that we want this behavior, I can add it.

I think making (bool)GMP(0) be false and (bool)GMP(others) true may make
sense. Though of course that would require people who check various
factory methods by doing != false or such be extra careful to use !== or
something like that. But that should be the case even now.

-- 
Stanislav Malyshev, Software Architect
SugarCRM: http://www.sugarcrm.com/
(408)454-6900 ext. 227

---

## #70946 — Yasuo Ohgaki — 2013-12-31T21:52:43+00:00

URL: https://externals.io/message/70940#70946 · In reply to: #70942

Hi Sara,



> On float support in GMP extension: Big +1, and I'd be happy to implement
> it.


I appreciate if you implement it!
I'll concentrate on encoding and session improvement :)

Anyway, we already got new year.
Happy new year to all of folks!

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #70997 — Sara Golemon — 2014-01-04T07:07:06+00:00

URL: https://externals.io/message/70940#70997 · In reply to: #70946

> 
> > […]
>
> I appreciate if you implement it!
> I'll concentrate on encoding and session improvement :)
>
I've pulled the GMP float proposal out of
https://wiki.php.net/rfc/gmp_number and fleshed it out a bit as
https://wiki.php.net/rfc/gmp-floating-point

-Sara

---

## #71001 — Yasuo Ohgaki — 2014-01-04T19:32:51+00:00

URL: https://externals.io/message/70940#71001 · In reply to: #70997

Hi Sara,



> 
> > […]
> I've pulled the GMP float proposal out of
> https://wiki.php.net/rfc/gmp_number and fleshed it out a bit as
> https://wiki.php.net/rfc/gmp-floating-point


I don't mind removing old RFC at all.
I moved my RFC to "Withdrawn" section as reference.
Thank you for your effort!

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net

---

## #96106 — Yasuo Ohgaki — 2016-09-23T08:45:30+00:00

URL: https://externals.io/message/70940#96106 · In reply to: #70997

Hi Sara,


> 
> > […]
> I've pulled the GMP float proposal out of
> https://wiki.php.net/rfc/gmp_number and fleshed it out a bit as
> https://wiki.php.net/rfc/gmp-floating-point

Any updates on this?

Regards,

--
Yasuo Ohgaki
yohgaki@ohgaki.net
