From:             biowep at gmail dot com
Operating system: Windows 7 x64 SP1
PHP version:      5.4.14
Package:          *Programming Data Structures
Bug Type:         Bug
Bug description:Casting from string containing exponential notation number to 
int

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 bug report at https://bugs.php.net/bug.php?id=64668&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=64668&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=64668&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=64668&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=64668&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=64668&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=64668&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=64668&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=64668&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=64668&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=64668&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=64668&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=64668&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=64668&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=64668&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=64668&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=64668&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=64668&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=64668&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=64668&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=64668&r=mysqlcfg

Reply via email to