[Tex/LaTex] How to divide two values in LaTex

programming

I need to divide two values in LaTex,

\newcommand{\x}{30}
\newcommand{\y}{10}

Is there a simple way to do this? i.e

x / y = 3

Preferably not using external packages, or a long winded \newcommand function. It needs to be as simple as possible. Also I may need to divide floats by integer values.

Best Answer

I don' know if this would be enough, but for your example it's enough (it requires eTeX)

\documentclass{scrartcl}
\def\basiceval#1{\the\numexpr#1\relax}
\begin{document}
\def\x{30}
\def\y{10}
\basiceval{\x/\y}
\end{document}
Related Question