#22173 [Opn->Ver]: Strange behaviour with the string 'inf'

From: Date: Thu, 13 Feb 2003 04:02:44 +0000
Subject: #22173 [Opn->Ver]: Strange behaviour with the string 'inf'
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-32962@lists.php.net to get a copy of this message
ID: 22173 Updated by: sniper@php.net Reported By: afenoy@wol.es -Status: Open +Status: Verified Bug Type: Scripting Engine problem Operating System: Linux -PHP Version: 4.2.1 +PHP Version: 4.3.1-dev New Comment: verified with PHP 4.3.1-dev.. Previous Comments: ------------------------------------------------------------------------ [2003-02-12 12:46:21] helly@php.net We're already discussing this - so reopening was valid. ------------------------------------------------------------------------ [2003-02-12 05:16:36] afenoy@wol.es Re-open: at least with single three characters 'inf', this is a bug and not a 'functionality'. ------------------------------------------------------------------------ [2003-02-12 04:38:17] afenoy@wol.es Ok, double-checked the documentation: this behavior of 'inf...' strings seems absolutely undocumented. Auto-convertion of any string that begins by 'inf' in infinite seems to me inadequate. Considering that this 'functionality' has not been documented, would be desirable to create a new predefined constant INF or a new data type INF or a new reserved word INF to treat infinite numbers, in the same form in which NULL, TRUE or FALSE correspond to predefined values. Consider that when we locked up 'NULL', 'TRUE' or 'FALSE' in a string, they are not evaluated like the corresponding constants. The same behavior would be desirable with a (new) predefined constant INF. And at least an error exists now in the form in which the strings that begin by 'inf' are treated. The strings of more than 3 characters ('information', 'infant' ...) are evaluated as INF in the comparisons with numbers, but the string 'inf', with single three characters, does not. Try this: <? echo (double)'information', '<br>'; echo (double)'inf' , '<br>'; echo 'information' > 1 ? 1 : 0, '<br>'; echo 'inf' > 1 ? 1 : 0, '<br>'; ?> Result: INF INF 1 0 Saludos Àngel ------------------------------------------------------------------------ [2003-02-11 17:11:20] iliaa@php.net Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.php.net/manual/ and the instructions on how to report a bug at http://bugs.php.net/how-to-report.php When performing a mathematical calculation between a number and a string in PHP, PHP will attempt to convert the string to an integer. Since PHP supports things such as INF certain strings, such as 'inf more data' will be converted to INF. ------------------------------------------------------------------------ [2003-02-11 13:55:05] afenoy@wol.es Very strange bug: (double) of any string begining with 'inf' evaluates as 'INF', but only in strings of more than 3 characters a comparison with a integer results in same bug. Try this script: <? echo 'somestring' > 1 ? 1 : 0, '<br>'; echo 'inf' > 1 ? 1 : 0, '<br>'; echo 'info' > 1 ? 1 : 0, '<br>'; echo 'inf at begin' > 1 ? 1 : 0, '<br>'; echo (double)'somestring', '<br>'; echo (double)'inf', '<br>'; echo (double)'inf at begin', '<br>'; ?> Expected results are: 0 0 0 0 0 0 0 But real results are: 0 0 1 1 0 INF INF Saludos Àngel ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=22173&edit=1

« previous php.bugs (#32962) next »