note 49371 added to language.operators.arithmetic
| From: | justin at koivi dot com | Date: | Tue, 25 Jan 2005 21:08:51 +0000 |
| Subject: | note 49371 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-83942@lists.php.net to get a copy of this message | ||
A note about the documentation on this page that I found while teaching a PHP class:
The above statment: "The division operator ("/") returns a float value anytime, even
if the two operands are integers (or strings that get converted to integers)." is NOT TRUE.
Take the following:
<?php
$a=5;
$b=10;
$c=$b/$a;
$d=10/5;
var_dump($c);
var_dump($d);
var_dump($b/$a);
var_dump(10/5);
?>
All 4 instances will print "int(2)"
Therefore, the division operator "/" returns an integer value if the numbers are evenly
divisible AND they are both integers (or strings that have been converted to integer values).
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+49371
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+49371&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+49371&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+49371&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+49371&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+49371&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+49371&report=yes
Search -- http://master.php.net/manage/user-notes.php