I've tried some examples with counters and numbers in LaTeX. I create a counter with \newcounter. I understand that it declares an integer. So if we make like this
\newcounter{num}
\setcounter{num}{10}
\divide\value{num} by 4\relax
\thenum
the result will be 2. It is an integer division (div) and the fractional part of the result is being neglected. Is there an opportunity to get 2.5 as a result in the example above? Maybe here we must define not a counter but a kind of float number? I also tried \newcount but the result is the same. Well, a count is an integer... Also I tried an example with \newlength:
\newlength\x
\setlength{\x}{10cm}
\divide\x by 4\relax
\the\x
The result is in pt's and if to convert it to cm's it would be about 2.5 cm. But I don't need lengths -- I am interested in just numbers. So how to define a float number and perform basic operations with it? Can we achieve this without using extra packages but with basic TeX/LaTeX capabilities?
\fpeval{10/4}will give 2.5. Or\newcommand\mynumber{10}\edef\mynumber{\fpeval{\mynumber/4}} \mynumber(there are also fp-variables in the expl3-layer.) – Ulrike Fischer Oct 14 '23 at 11:23\fpeval– David Carlisle Oct 14 '23 at 11:33\hfillstretches) all tex length calculations are integer calculation inspunits and just use decimalptvalue for display – David Carlisle Oct 14 '23 at 11:46