If you need only addition, subtraction and multiplication and numbers are expected in the range +-16380 with four (or less) digits after decimal point then you can use directly dimension registers supported naturally by TeX. For example:
\def\newreg{\csname newdimen\endcsname}
\def\setreg#1#2{#1=#2pt }
\def\addreg#1#2{\advance#1by#2pt }
\def\mulreg#1#2{#1=#2#1}
\def\valuereg#1{\expandafter\ignorept\the#1}
\bgroup\lccode`\?=`\p \lccode`\!=`\t \lowercase{\egroup\def\ignorept#1?!{#1}}
\newreg\myx
\setreg\myx {0.0}
\addreg\myx {0.5}
\addreg\myx {-0.25}
\valuereg\myx % this expands to 0.25
\bye
But division using dimension registers is somewhat more complicated.
Of course, you can use pgfmath
or calc
or lua
or expl3
or apnum
or somewhat similar but with declared needs it seems like using cannon on a sparrow.
\newdimen\myx
. Because this question is marked as "duplicate", I am unable to show full answer here. Unfortunately. – wipet Mar 14 '18 at 15:48\newdimen
. So, your decision about "duplicate question" yields to missing answer here. But OP understood my idea, fortunately. – wipet Mar 14 '18 at 20:08