I need to store and use a large amount of integers (a little bit of "programming with TeX"), but I know that TeX has a limited (up to 256) number of counters that can be used simultaneously. How to work with these numbers using macros? I need basic numerical operations and comparison.
|
|
||||
| show 1 more comment |
|
There is no real limitation nowadays if you use If you use constants less than "8000 = 32768, they can be conveniently stored with
allows you to use Note. A trick such as
doesn't work. This is because of a security precaution taken by TeX during assignments. When one says
the token
However, such computations are rather inefficient. |
|||||||||||
|
\chardefand\mathchardefwhich act basically like counters without needing a register. You can't add to them like with counter, however. – Martin Scharrer♦ May 15 '12 at 17:41\mathchardef\myconstant=<integer>. With e-TeX you can use e.g.\mathchardef\myotherconstant=\numexpr \myconstant + 1 \relaxto add one to this "constant", etc., but\myconstant=1doesn't work. A benefit is that it is a terminated number and TeX will not expand further tokens to look for more potential digits like it does with macros. – Martin Scharrer♦ May 15 '12 at 17:49