note 50318 added to function.fmod
| From: | samdotfullmanatverizon at osu1 dot php dot net | Date: | Thu, 24 Feb 2005 15:30:02 +0000 |
| Subject: | note 50318 added to function.fmod | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-85498@lists.php.net to get a copy of this message | ||
This function behaves wierd in negative regions. If you have something like an angle that goes
through 360 degress of rotation and your angle goes negative, then fmod of -1 should be 359, right?
Here's a way to get that result, so that you get a phase shift vs. just a "negative
fmod":
$h= -30; //same as 330 degrees
//handle negative
if($h<0){
while(true){
$fail++; if($fail>100)break; //in case loop gets tied up
$h+=360;
if($h>=0)break;
}
}
$h=fmod($h,360);
echo $h; //will say 330 degrees - we phase shifted up until positive.
----
Manual Page -- http://www.php.net/manual/en/function.fmod.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+50318
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+50318&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+50318&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+50318&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+50318&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+50318&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+50318&report=yes
Search -- http://master.php.net/manage/user-notes.php