IS THERE A FUNCTION TO DETERMINE ODD AND EVEN NUMBERS
IS THERE A FUNCTION TO DETERMINE ODD AND EVEN NUMBERS
(OP)
Hi everyone
I'm in nx6 and trying to create an if/then based on X being odd or even. example if(x==odd)(1)else(0)
Is there such a function or work around?
thanks for your time.
I'm in nx6 and trying to create an if/then based on X being odd or even. example if(x==odd)(1)else(0)
Is there such a function or work around?
thanks for your time.





RE: IS THERE A FUNCTION TO DETERMINE ODD AND EVEN NUMBERS
test=mod(x,2)
If x is ODD, test=1
If x is EVEN, test=0
Note that 'mod' is known as the 'Modulus' function and is documented in the Expression system's Function section under 'Math'.
John R. Baker, P.E.
Product 'Evangelist'
Product Design Solutions
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
http://www.siemens.com/plm
http://www.plmworld.org/museum/
To an Engineer, the glass is twice as big as it needs to be.
RE: IS THERE A FUNCTION TO DETERMINE ODD AND EVEN NUMBERS
test=mod(abs(x),2)
...as this will remove the effect of the sign of 'x' from the value of 'test'.
John R. Baker, P.E.
Product 'Evangelist'
Product Design Solutions
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
http://www.siemens.com/plm
http://www.plmworld.org/museum/
To an Engineer, the glass is twice as big as it needs to be.
RE: IS THERE A FUNCTION TO DETERMINE ODD AND EVEN NUMBERS