|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2001-12-05 13:06 UTC] ruud at stress dot utwente dot nl
[2001-12-13 20:31 UTC] yohgaki@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sat Oct 25 14:00:01 2025 UTC |
Hi, Please take a look at this PHP script. <?php for($j=0; $j<1000; $j++) { $result=71.95; $price=utf8_encode($result); $price = $price * 2.2 / 2.2; echo "$price<br>\n"; } ?> This script should just output 1000x exactly the same but as you can see, the script sometimes returns "71" instead of "71.95". Seems to have to do something with type juggling. If we explecitly cast price to a float, ["$price=(float)utf8_encode($result);"] the script returns only the correct value.