#48573 [Opn]: E-notated strings improperly cast as integers

From: Date: Tue, 16 Jun 2009 19:54:38 +0000
Subject: #48573 [Opn]: E-notated strings improperly cast as integers
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-138373@lists.php.net to get a copy of this message
ID: 48573 User updated by: josh at mykoala dot com Reported By: josh at mykoala dot com Status: Open Bug Type: *Programming Data Structures Operating System: Mac OS X 10.5.7 PHP Version: 5.2.9 New Comment: > When an E notated integer When an E notated float* intval() on the string also (predictably) produces the same result as casting to int Previous Comments: ------------------------------------------------------------------------ [2009-06-16 19:08:10] josh at mykoala dot com Description: ------------ When an E notated integer is in a string, and you try to cast it to an integer, the value stops at anything non-integer, reducing the ability to cast notated numbers. It does not first check or convert the value to a float to account for E notation. The documentation on type juggling doesn't mention this limitation, and it is not the expected result. Reproduce code: --------------- $ php -r 'var_dump((int)"5.6401418785e+05");' int(5) $ php -r 'var_dump((int)5.6401418785e+05);' int(564014) $ php -r 'var_dump((int)(float)"5.6401418785e+05");' int(564014) ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=48573&edit=1

« previous php.bugs (#138373) next »