Bug #73329 [Ver->Csd]: (Float)"Nano" == NAN [Should return me 0]

From: Date: Tue, 18 Oct 2016 17:15:41 +0000
Subject: Bug #73329 [Ver->Csd]: (Float)"Nano" == NAN [Should return me 0]
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-204899@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73329&edit=1 ID: 73329 Updated by: ab@php.net Reported by: nikcomestotalk at gmail dot com Summary: (Float)"Nano" == NAN [Should return me 0] -Status: Verified +Status: Closed Type: Bug Package: Scripting Engine problem Operating System: Any PHP Version: 7.0.12 Block user comment: N Private report: N New Comment: Automatic comment on behalf of ab Revision: http://git.php.net/?p=php-src.git;a=commit;h=9f2ab75b1096b881ee97eb2b436763aa14c19635 Log: Fixed bug #73329 (Float)&quot;Nano&quot; == NAN Previous Comments: ------------------------------------------------------------------------ [2016-10-17 17:33:57] nikcomestotalk at gmail dot com Status ? Not intentional, it somehow got changed ------------------------------------------------------------------------ [2016-10-17 17:24:33] requinix@php.net Did you mean to close this? > we in mood of going strict data types in future Not really, no. (float)"123abc" === 123.0 for sure, and (float)"information" === INF or 0.0 depending on what happens with this bug report. ------------------------------------------------------------------------ [2016-10-17 17:17:05] nikcomestotalk at gmail dot com I understand the complexity of this but are we in mood of going strict data types in future. (float)"123abc" should return "NAN" (float)"information" should return "NAN" not "INF" ------------------------------------------------------------------------ [2016-10-17 14:38:06] requinix@php.net > simply ignoring unrecognized trailing characters is normal behavior Which makes sense (sort of) when it's converting something which is recognizably a number. To a human, "123abc" is formed of two parts ("123" and "abc") and getting a result of 123 makes sense because that's what the first part represents. But "nano" looks like just one part, and since it doesn't represent a number I think the result should be 0 - just like it would be with "mini" or "touch". If (float)"Nan0" == NAN and (float)"Inf!nity" == INF then that'd be alright to me. ------------------------------------------------------------------------ [2016-10-17 13:48:54] cmb@php.net I'm not sure if that qualifies as bug; simply ignoring unrecognized trailing characters is normal behavior of float conversion, see <https://3v4l.org/F18FJ> and even <https://3v4l.org/dYHtG>. (I don't find this behavior particularly useful, but we have it.) ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at https://bugs.php.net/bug.php?id=73329 -- Edit this bug report at https://bugs.php.net/bug.php?id=73329&edit=1

« previous php.bugs (#204899) next »