note 106017 added to function.intval
| From: | wgh at osu1 dot php dot net | Date: | Mon, 03 Oct 2011 12:39:45 +0000 |
| Subject: | note 106017 added to function.intval | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-183596@lists.php.net to get a copy of this message | ||
Someone can tell me why
<?php
$full = str_replace("⬠", "", "⬠10.50");
$discounted = str_replace("⬠", "", "⬠8.40");
$full = floatval($full);
$discounted = floatval($discounted);
echo $percent = ($full - $discounted) / $full;
echo $percent = intval($percent * 100);
?>
The result of the 2 echos is
⢠0.2
⢠19
Why I get 19 and not 20?!
----
Server IP: 195.54.192.44
Probable Submitter: 127.0.0.1
----
Manual Page -- http://www.php.net/manual/en/function.intval.php
Edit -- https://master.php.net/note/edit/106017
Del: integrated -- https://master.php.net/note/delete/106017/integrated
Del: useless -- https://master.php.net/note/delete/106017/useless
Del: bad code -- https://master.php.net/note/delete/106017/bad+code
Del: spam -- https://master.php.net/note/delete/106017/spam
Del: non-english -- https://master.php.net/note/delete/106017/non-english
Del: in docs -- https://master.php.net/note/delete/106017/in+docs
Del: other reasons-- https://master.php.net/note/delete/106017
Reject -- https://master.php.net/note/reject/106017
Search -- https://master.php.net/manage/user-notes.php