PDA

View Full Version : Any programmers here?


thirddan
10-25-2004, 06:46 AM
Im taking a class at school where i need to do some scripting to control some dynamic simulations for my visual effects class. The language is called MEL (Maya Embedded Language) for the 3d program Maya, its similar to C...

Is there a function out there (or that could be written) that would allow me to return a value of 1 if a math operatoin returns a whole number and a 0 if the operation returns a float/decimal number?

RocketManJames
10-25-2004, 06:52 AM
I'll speak in C. Not sure if it'll work for you.

Say I have a floating point variable, f.

(int)f truncates the fraction.

So, if( f - (int)f != 0 ), then you have a non-whole number.

-RMJ

challenger84
10-25-2004, 06:55 AM
I think in C, it would be:

x % 1 : 0 ? 1


Jeez, it's been a while so I'm not sure if that's the right syntax, but pretty much if x % 1 == 0 return 1 else return 0

thirddan
10-25-2004, 07:15 AM
thanks for the quick responses...

i ended up using the remainder % operator and it worked, maybe when i figure out this stuff and finish my midterms i can play/post poker...