# [Tex/LaTex] The difference between \the\numexpr and \number\numexpr

e-textex-core

I wonder if there is any functional difference between \the\numexpr and \number\numexpr. Some obscure context where they would yield different results?

(I'm obviously aware that \the and \number differ, wildly. I'm just curious about the case where they are followed by \numexpr.)

While it seems that there is no difference in semantics (but I'm still waiting for answers here), there seems to be a small but consistent difference in performance.

First, \the consists of 4 characters and \number of 7, so you can type it almost twice as fast! ;-)

Seriously, \the\numexpr seems to be 10 - 15% faster than \number\numexpr. As it's not absolutely trivial to measure this, this is how I did it.

I ran pgf's profiler library on these three loops:

L1. \edef\a{\the\numexpr 40+2}

L2. \edef\a{\number\numexpr 40+2}

L3. \edef\a{}

... in the hope that subtracting the execution time of L3 from L1 (L2) gives me the time actually spent in \the\numexpr (\number\numexpr). (L1-L3) / (L2-L3) then yields about 85 - 90%.

To get a rough feel for the actual speed: a million repetitions of \the\numexpr takes about a second on my computer.