rfc:gmp_number

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
rfc:gmp_number [2013/12/30 23:37] – created yohgakirfc: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 (?)</del>
  
-==== Add GMP float support to Zend OP ===== +Extracted out to a separate RFC: [[rfc:gmp-floating-point|GMP Floating Point Support]]
-Add GMP float support to operators. +
- +
-  * Arithmetic with GMP float and any number(PHP int/float, GMP int) is promoted to GMP float.+
  
 ==== 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)#3 (1) { 
 +    ["num"]=> 
 +    string(1) "0" 
 +  } 
 +  php > $v = $g * 0; 
 +   
 +  php > var_dump($v, empty($v), is_scalar($v)); 
 +  object(GMP)#4 (1) { 
 +    ["num"]=> 
 +    string(3) "0" 
 +  } 
 +  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()/min() 
 +  php > $g = gmp_init(123); 
 +  php > var_dump($v); 
 +  object(GMP)#4 (1) { 
 +    ["num"]=> 
 +    string(1) "0" 
 +  } 
 +  php > $g = gmp_init(5); 
 +  php > var_dump(max(1,2,$g)); 
 +  object(GMP)#1 (1) { 
 +    ["num"]=> 
 +    string(1) "5" 
 +  } 
 +  php > var_dump(min(1,2,$g)); 
 +  int(1) 
 +  php > var_dump(min($g, 6, 7)); 
 +  object(GMP)#1 (1) { 
 +    ["num"]=> 
 +    string(1) "5" 
 +  }
  
-  * hardcoded default values 
-     * gmp_precision=256 
  
-  * php.ini-development values +== Current Ruby and PHP behavior == 
-     * gmp_precision=256+  [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 > 
  
-  php.ini-production values +  [yohgaki@dev php-src]$ php -a 
-     * gmp_precision=256+  Interactive shell 
 +   
 +  php > $g gmp_init('10'); 
 +  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 =====
  
   * 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?)
  
 ===== Future Scope ===== ===== Future Scope =====
Line 100: Line 156:
  
   * https://wiki.php.net/rfc/operator_overloading_gmp   * https://wiki.php.net/rfc/operator_overloading_gmp
 +  * https://wiki.php.net/rfc/autoboxing
  
 ===== Rejected Features ===== ===== Rejected Features =====
  
 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.1388446620.txt.gz · Last modified: 2017/09/22 13:28 (external edit)