GMP Shift And Power Operators Deprecate Float Operands
The **, << and >> operators accept a float as the non-GMP operand when the other operand is a GMP object. Until PHP 8.6, a float such as 2.5 was silently truncated to an integer before being used as the exponent or shift amount, discarding its fractional part without warning. In PHP 8.6, a float that would lose precision when converted emits a deprecation notice, Implicit conversion from float 2.5 to int loses precision, before still truncating it the same way.
PHP code
<?php
var_dump(gmp_strval(gmp_init(2) ** 2.5));
var_dump(gmp_strval(gmp_init(8) << 2.5));
?>
Before
string(1) "4"
string(2) "32"
After
PHP Deprecated: Implicit conversion from float 2.5 to int loses precision in /codes/gmpFloatOperandDeprecated.php on line 3
Deprecated: Implicit conversion from float 2.5 to int loses precision in /codes/gmpFloatOperandDeprecated.php on line 3
string(1) "4"
PHP Deprecated: Implicit conversion from float 2.5 to int loses precision in /codes/gmpFloatOperandDeprecated.php on line 4
Deprecated: Implicit conversion from float 2.5 to int loses precision in /codes/gmpFloatOperandDeprecated.php on line 4
string(2) "32"
PHP version change
This behavior was deprecated in 8.6.
This behavior changed in .