Edit report at https://bugs.php.net/bug.php?id=64668&edit=1

 ID:                 64668
 Updated by:         johan...@php.net
 Reported by:        biowep at gmail dot com
 Summary:            Casting from string containing exponential notation
                     number to int
-Status:             Open
+Status:             Not a bug
 Type:               Bug
 Package:            *Programming Data Structures
 Operating System:   Windows 7 x64 SP1
 PHP Version:        5.4.14
 Block user comment: N
 Private report:     N

 New Comment:

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

the cast from string to int cuts the number of on the first non-digit 
(essentially using the system's atoi() function) this is expected behavior.


Previous Comments:
------------------------------------------------------------------------
[2013-04-18 17:34:06] biowep at gmail dot com

Description:
------------
When trying to cast a numeric string value in the exponential notation to int, 
the 
result doesn't match with the initial value. While the casting to float from 
string works well. Also casting to int from the same value stored in a float 
variable workes well.
The function intval() has the same problem.

Test script:
---------------
<?php

echo 1E2 . "<br />";
echo (float)1E2 . "<br />";
echo (int)1E2 . "<br />";
echo intval(1E2) . "<br />";
echo (float)"1E2" . "<br />";
echo (int)"1E2" . "<br />";//problem
echo intval("1E2") . "<br />";//problem

?>

Expected result:
----------------
100
100
100
100
100
100
100

Actual result:
--------------
100
100
100
100
100
1
1


------------------------------------------------------------------------



-- 
Edit this bug report at https://bugs.php.net/bug.php?id=64668&edit=1

Reply via email to