rfc:gmp_number

Differences

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

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
rfc:gmp_number [2013/12/30 23:40] yohgakirfc: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)#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)
 +
 +
 +== 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)#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"
 +  }
 +
 +
 +== 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('10');
 +  php > echo $g / 3;
 +  3
 +  
 +  php > echo 10 / 3;
 +  3.3333333333333
  
 ===== Backward Incompatible Changes ===== ===== Backward Incompatible Changes =====
Line 82: Line 154:
   * How GMP number should behave (Like PHP or Ruby?)   * How GMP number should behave (Like PHP or Ruby?)
   * GMP float support API design   * GMP float support API design
 +  * gmp_precision default value
  
 ===== Future Scope ===== ===== Future Scope =====
rfc/gmp_number.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1