note 24546 added to language.types.type-juggling
| From: | amittai at NOSPAMamittai dot com | Date: | Wed, 21 Aug 2002 03:30:01 +0000 |
| Subject: | note 24546 added to language.types.type-juggling | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-35290@lists.php.net to get a copy of this message | ||
Uneven division of an integer variable by another integer variable will result in a float by
automatic conversion -- you do not have to cast the variables to floats in order to avoid integer
truncation (as you would in C, for example):
$dividend = 2;
$divisor = 3;
$quotient = $dividend/$divisor;
print $quotient; // 0.66666666666667
Amittai Aviram
--
http://www.php.net/manual/en/language.types.type-juggling.php
http://master.php.net/manage/user-notes.php?action=edit+24546
http://master.php.net/manage/user-notes.php?action=delete+24546
http://master.php.net/manage/user-notes.php?action=reject+24546