I would like to know how to check properly for evenness or oddness within some macro. I have played a little with fp and pgfmath package, but it seems I am not keen enough in TeX to do it properly. Here is a sample example where I try to check evenness of 2 parameters:
\documentclass{article}
\usepackage{tikz}
\def\IfEven#1{\pgfmathparse{int(mod(#1,2))}\ifnum\pgfmathresult=0}
\newcommand{\parity}[2]{%
\def\x{#1}%
\def\y{#2}%
\IfEven{\x}%
\IfEven{\y}%
{\x} and {\y} are even.%
\else%
{\x} is even and {\y} is odd.%
\fi%
\else%
\IfEven{\y}%
{\x} is odd and {\y} is even.%
\else%
{\x} and {\y} are odd.%
\fi%
%% If I put a second \fi here I got an error 'Extra \fi.', otherwise
%% it compiles and works fine but there are two warnings:
%% (\end occurred when \ifnum on line 28 was incomplete)
%% (\end occurred when \ifnum on line 26 was incomplete)
}
\begin{document}
\parity{0}{7}\\
\parity{3}{3}\\
\parity{2}{6}\\
\parity{1}{4}\\
\end{document}
I do understand that I should write a second \fi (but it does not compile). Otherwise, it compiles, displays what I was expecting, but I do not feel comfortable at all with the warnings... and I guess the more I will be using this macro, the more I will have warnings.
So If you have any suggestions...

\ifodd, so I think it would be simpler to use that.\ifodd\y odd code\else even code\fi. – Nicola Talbot Jun 23 '16 at 13:54\ifnumbeing hidden in the code that isn't executed. I think the problem is similar to that in Do all \if's need to be defined before a nested if? – Nicola Talbot Jun 23 '16 at 15:14