Page 1 of 1

Using modulus

Posted: Mon Jan 19, 2009 2:13 pm
by Ondra
Good day all. I would like to know when checking for a remainder using modulus is this correct: -
"var MOD 2 =0"? This would check for even numbers. If this is not right could someone give an example.
Thanks in advance

Ondra

Re: Using modulus

Posted: Mon Jan 19, 2009 4:19 pm
by chevy6600
Hi ondra, i used it in my servo program , this is what i used :

servo_val = ( servo_pos[port_counter] )
servo_l = ( servo_val MOD 3 ) * 85
servo_h = 31 + ( servo_val / 3 )

Re: Using modulus

Posted: Mon Jan 19, 2009 4:58 pm
by chevy6600
Hi ondra, i thought i would go one better than my last post. i have put a demo simple maths routine together, dowload the program `mod` and just run it so that you can see flowcode variables.

Re: Using modulus

Posted: Tue Jan 20, 2009 12:08 am
by Ondra
Thanks.