Newbies lake_shore Posted March 15, 2002 Newbies Posted March 15, 2002 Is there a simple calculation which can evaluate whether a number is odd or even?
SteveB Posted March 15, 2002 Posted March 15, 2002 Yes, it is called Modulo, or MOD for short. It returns the remainder of the integer division of a number. Lets say you have a number field called 'inum'. MOD(inum,2) will return either a 1 or a zero. If you would like the expression to return either 1 or 2, do the following: MOD(inum-1,2)+1. Since this is integer division and really only the remainder, it doesn't make any difference how big inum is: 1001 returns 1, 1002 return 2 (if you use the -1 and +1 expression).
Newbies lake_shore Posted March 15, 2002 Author Newbies Posted March 15, 2002 Thank you for the fast reply. Just what I needed.
Alan Betts Posted March 15, 2002 Posted March 15, 2002 This calculation can also be used to differentiate odd and even weeks if the number involved is a week(date) calculation. e.g - assuming field week number is week(date) calc Case(mod(week number;2) = 1; "odd week";"even week") This is useful if you have to set startup scripts do things on a fortnightly basis. (Just thought I'd throw it in for anyone who is interested)
Recommended Posts
This topic is 8360 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now