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

 ID:                 21459
 Comment by:         simpson at wp dot pl
 Reported by:        bibifoc23 at yahoo dot fr
 Summary:            converting float to int failed sometime
 Status:             Bogus
 Type:               Bug
 Package:            Scripting Engine problem
 Operating System:   linux and windows
 PHP Version:        4.3.0
 Block user comment: N

 New Comment:

$val = 32.48;

var_dump($val); // float(32.48);

$val = $val * 100;

var_dump($val); // float(3248);

var_dump((int)$val); // int(3247)

var_dump((int)(string)$val); // int(3248)



Why not to add double conversion at the source code level instead of
.php level?

So the (int) would do (int)(string)$val



I tested this with milions of options and allways worked as i expected.



Cheers.


Previous Comments:
------------------------------------------------------------------------
[2003-01-06 06:18:34] [email protected]

Please do not submit the same bug more than once. An existing
bug report already describes this very problem. Even if you feel
that your issue is somewhat different, the resolution is likely
to be the same. Because of this, we hope you add your comments
to the existing bug instead.

Thank you for your interest in PHP.



------------------------------------------------------------------------
[2003-01-06 05:17:00] bibifoc23 at yahoo dot fr

<?php



$nb = (15.2 - 15) * 100;

echo $nb."\n";

echo (int)$nb; 



?>



The output should be 20 and 20, but it's  20 and 19 !!!!



this strange behavior does not appear for all value.



I test on Redhat 6.2 and windows 2000 SP3



I think there was a link to another bug n°21458



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



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

Reply via email to