note 34866 added to language.operators.arithmetic

From: Date: Fri, 08 Aug 2003 22:37:07 +0000
Subject: note 34866 added to language.operators.arithmetic
Groups: php.notes 
Request: Send a blank email to php-notes+get-53710@lists.php.net to get a copy of this message
saforres@alumni.SPAMGUARD.uwaterloo.ca told us that: "This sort of strategy will not work. Suppose $foo=9999999 and $bar=10000000. Then since $foo<$bar, you would want int($foo/$bar) to return 0, but 9999999/10000000+0.0000001=1.000000000, so (int)($foo / $bar + 0.0000001)=1." I have an idea that will get integer division to work. If you just do it like this: (int)(($foo+0.01)/$bar) (providing of course $foo is an integer as well), it'll work. ---- Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php Edit Note -- http://master.php.net/manage/user-notes.php?action=edit+34866 Delete Note -- http://master.php.net/manage/user-notes.php?action=delete+34866&report=yes Reject Note -- http://master.php.net/manage/user-notes.php?action=reject+34866&report=yes

« previous php.notes (#53710) next »