|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-03-25 14:28 UTC] vivekanandan8 at yahoo dot com
Description: ------------ Generally when integer number exceed(overflows), it is converted to float,But for the number -2147483648 the Integer can hold, but converted to float. Reproduce code: --------------- <? $vValue = (int)-2147483648; var_dump($vValue); $vValue = -2147483648; var_dump($vValue); ?> Expected result: ---------------- int(-2147483648) int(-2147483648) Actual result: -------------- int(-2147483648) float(-2147483648) PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Dec 05 04:00:01 2025 UTC |
Hi, Thanks for your information.but when the overflow occurs at the runtime, then also the data type conversion does not change. Ex: <? $vValue = -2147483649; var_dump($vValue); //output: float(-2147483649) $vValue++; var_dump($vValue);//output: float(-2147483648) $vValue++; var_dump($vValue);//output: float(-2147483647) ?> Initially $vValue is double , but even later execution it is not converted to integer when it can hold values. when the overflow occurs we convert from long to double but i fell it is not done from double to long. Hence in the function increment_function(zend_operators.c) we have to add the validation as follows case IS_DOUBLE: if(op1->value.dval == LONG_MIN) { op1->value.lval = (long) op1->value.dval+1; op1->type = IS_LONG; }else{ op1->value.dval = op1->value.dval + 1; }