note 71403 added to language.operators.arithmetic
| From: | jon_rhoades at yahoo dot com | Date: | Mon, 27 Nov 2006 12:48:54 +0000 |
| Subject: | note 71403 added to language.operators.arithmetic | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-120100@lists.php.net to get a copy of this message | ||
Jonathon Reinhart's neat little function to find out if a value is odd or even doesn't
work for floats (this might possibly arithmetically correct but causes the following problem) eg
<?php
12.23 % 2 = 0 not 1
?>
So if you need to find out if the fraction part of a float is odd or even try:
<?php
if (($a /2) != (floor($a /2))){
echo "$a is odd." ;
}
if (($a /2) == (floor($a /2))){
echo "$a is even." ;
}
?>
----
Server IP: 85.116.0.130
Probable Submitter: 62.69.39.224
----
Manual Page -- http://www.php.net/manual/en/language.operators.arithmetic.php
Edit -- https://master.php.net/note/edit/71403
Del: integrated -- https://master.php.net/note/delete/71403/integrated
Del: useless -- https://master.php.net/note/delete/71403/useless
Del: bad code -- https://master.php.net/note/delete/71403/bad+code
Del: spam -- https://master.php.net/note/delete/71403/spam
Del: non-english -- https://master.php.net/note/delete/71403/non-english
Del: in docs -- https://master.php.net/note/delete/71403/in+docs
Del: other reasons-- https://master.php.net/note/delete/71403
Reject -- https://master.php.net/note/reject/71403
Search -- https://master.php.net/manage/user-notes.php