rfc:gmp_number
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
rfc:gmp_number [2013/12/30 23:40] – yohgaki | rfc:gmp_number [2017/09/22 13:28] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 23: | Line 23: | ||
==== Add GMP float support to GMP module ==== | ==== Add GMP float support to GMP module ==== | ||
- | Add GMP float support to GMP module. | + | <del>Add GMP float support to GMP module. |
* Add all GMP float API wrapper to module. | * Add all GMP float API wrapper to module. | ||
* GMP float API wrapper supports PHP int/float and GMP int/float. Conversion is done automatically. | * GMP float API wrapper supports PHP int/float and GMP int/float. Conversion is done automatically. | ||
- | * Default precision: 256 (?) | + | * Default precision: 256 (?)</ |
- | ==== Add GMP float support to Zend OP ===== | + | Extracted out to a separate RFC: [[rfc: |
- | Add GMP float support to operators. | + | |
- | + | ||
- | * Arithmetic with GMP float and any number(PHP int/float, GMP int) is promoted | + | |
==== Add math function compatibility ===== | ==== Add math function compatibility ===== | ||
Line 50: | Line 47: | ||
- | ===== Backward Incompatible Changes | + | ===== References |
+ | == Current empty() and is_scalar() behavior == | ||
- | ===== Proposed PHP Version(s) ===== | + | [yohgaki@dev php-src]$ ./php-bin -a |
+ | Interactive shell | ||
- | PHP 5.6 or later | + | php > $g = gmp_init(123); |
+ | php > var_dump($v); | ||
+ | object(GMP)# | ||
+ | [" | ||
+ | string(1) " | ||
+ | } | ||
+ | php > $v = $g * 0; | ||
+ | |||
+ | php > var_dump($v, | ||
+ | object(GMP)# | ||
+ | [" | ||
+ | string(3) " | ||
+ | } | ||
+ | bool(false) | ||
+ | bool(false) | ||
- | ===== Impact to Existing Extensions ===== | ||
- | GMP module will have GMP float support. | + | == Current math function behavior == |
- | ===== php.ini Defaults ===== | + | GMP float is not supported. |
+ | php > $f = 2.2; | ||
+ | php > $gf = gmp_init($f); | ||
+ | |||
+ | Warning: gmp_init(): Unable to convert variable to GMP - wrong type in php shell code on line 1 | ||
- | If there are any php.ini settings then list: | + | max()/ |
+ | | ||
+ | php > var_dump($v); | ||
+ | object(GMP)# | ||
+ | [" | ||
+ | string(1) " | ||
+ | } | ||
+ | php > $g = gmp_init(5); | ||
+ | php > var_dump(max(1, | ||
+ | object(GMP)# | ||
+ | [" | ||
+ | string(1) " | ||
+ | } | ||
+ | php > var_dump(min(1, | ||
+ | int(1) | ||
+ | php > var_dump(min($g, | ||
+ | object(GMP)# | ||
+ | [" | ||
+ | string(1) " | ||
+ | } | ||
- | * hardcoded default values | ||
- | * gmp_precision=256 | ||
- | * php.ini-development values | + | == Current Ruby and PHP behavior == |
- | * gmp_precision=256 | + | [yohgaki@dev |
+ | | ||
+ | => 3 | ||
+ | 2.0.0p247 :002 > 10.0 / 3 | ||
+ | => 3.3333333333333335 | ||
+ | 2.0.0p247 :003 > | ||
- | | + | |
- | * gmp_precision=256 | + | |
+ | |||
+ | php > $g = gmp_init(' | ||
+ | php > echo $g / 3; | ||
+ | 3 | ||
+ | |||
+ | php > echo 10 / 3; | ||
+ | 3.3333333333333 | ||
+ | |||
+ | ===== Backward Incompatible Changes ===== | ||
+ | |||
+ | |||
+ | ===== Proposed PHP Version(s) ===== | ||
+ | |||
+ | PHP 5.6 or later | ||
===== Open Issues ===== | ===== Open Issues ===== | ||
Line 81: | Line 133: | ||
* Implement autoboxing like feature | * Implement autoboxing like feature | ||
* How GMP number should behave (Like PHP or Ruby?) | * How GMP number should behave (Like PHP or Ruby?) | ||
- | * GMP float support API design | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
Line 110: | Line 161: | ||
Keep this updated with features that were discussed on the mail lists. | Keep this updated with features that were discussed on the mail lists. | ||
- | |||
- |
rfc/gmp_number.1388446838.txt.gz · Last modified: 2017/09/22 13:28 (external edit)