rfc:gmp_number
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionNext revisionBoth sides next revision | ||
rfc:gmp_number [2013/12/30 23:37] – created yohgaki | rfc:gmp_number [2013/12/30 23:57] – yohgaki | ||
---|---|---|---|
Line 49: | Line 49: | ||
+ | |||
+ | ===== References ===== | ||
+ | |||
+ | == Current empty() and is_scalar() behavior == | ||
+ | |||
+ | [yohgaki@dev php-src]$ ./php-bin -a | ||
+ | Interactive shell | ||
+ | |||
+ | 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) | ||
+ | |||
+ | |||
+ | == Current math function behavior == | ||
+ | |||
+ | 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 | ||
+ | |||
+ | max()/min() | ||
+ | php > $g = gmp_init(123); | ||
+ | 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) " | ||
+ | } | ||
+ | |||
+ | |||
+ | == Current Ruby and PHP behavior == | ||
+ | [yohgaki@dev php-src]$ irb | ||
+ | 2.0.0p247 :001 > 10 / 3 | ||
+ | => 3 | ||
+ | 2.0.0p247 :002 > 10.0 / 3 | ||
+ | => 3.3333333333333335 | ||
+ | 2.0.0p247 :003 > | ||
+ | |||
+ | [yohgaki@dev php-src]$ php -a | ||
+ | Interactive shell | ||
+ | | ||
+ | php > $g = gmp_init(' | ||
+ | php > echo $g / 3; | ||
+ | 3 | ||
+ | | ||
+ | php > echo 10 / 3; | ||
+ | 3.3333333333333 | ||
===== Backward Incompatible Changes ===== | ===== Backward Incompatible Changes ===== | ||
Line 77: | Line 149: | ||
* Ways to implement GMP object evaluation in empty(), is_scalar() | * Ways to implement GMP object evaluation in empty(), is_scalar() | ||
+ | * Treat GMP object as special object | ||
+ | * Implement scalar object | ||
+ | * Implement autoboxing like feature | ||
+ | * How GMP number should behave (Like PHP or Ruby?) | ||
+ | * GMP float support API design | ||
+ | * gmp_precision default value | ||
===== Future Scope ===== | ===== Future Scope ===== | ||
Line 100: | Line 178: | ||
* https:// | * https:// | ||
+ | * https:// | ||
===== Rejected Features ===== | ===== Rejected Features ===== |
rfc/gmp_number.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1