FORUMS: list search recent posts

Scripting question - fmod

COW Forums : Autodesk Maya

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
Adam Benson
Scripting question - fmod
on Dec 27, 2009 at 2:06:53 am

Does anyone know if it's even possible to use the "fmod" command with a $variable? And if so, How? I can't get it to work but I NEED it to work, or I need another work around for getting the remainder of a set of values. Basically I need the equivalent of this equation:

$remainder = fmod $value1 15;

I have previously declared "$value1" as a float type, as well as the "$remainder" variable. Generally, this command is used like so:

fmod 12 15;

In this way the first number is divided by the second and the remainder is returned. It works fine purely numerically, but when I try to give it a variable it craps out.
Thanks in advance.
Adam

Adam Benson
Visual Effects Artist/Musician/Sound Engineer/Editor
http://www.SleepDeprivedProductions.com
http://www.SleepDeprivedFilms.com


Return to posts index

Adam Benson
Re: Scripting question - fmod
on Dec 27, 2009 at 3:05:55 am

For anyone who may be pondering this same issue, the problem was simple. According to the script reference, and when using real numbers the syntax above is correct. HOWEVER, when it comes to using variables (and this is NOT listed anywhere) you must alter the syntax as follows:

FROM:
$remainder = fmod $value1 15;

TO:
$remainder = fmod($value1, 15);

Essentially, by adding parenthesis around the fmod equation AND separating the two numbers by a comma the equation now works.

Thanks for anyone who may have solved this the same way!

Adam Benson
Visual Effects Artist/Musician/Sound Engineer/Editor
http://www.SleepDeprivedProductions.com
http://www.SleepDeprivedFilms.com


Return to posts index

Michiel Duvekot
Re: Scripting question - fmod
on Dec 27, 2009 at 3:22:50 am

use

float $mod = `fmod $x $y`;

or simply

float $mod = $x % $y;

Michiel
http://www.thnkr.com


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]