I want to check if the value of the parameter is negative. If the parameter is negative, I want to substract 0.5 and if it is positive, I want to add 0.5.
The best I could do is define new variable like this
\ifnum#1<0 \def\xa{#1-0.5} \else \def\xa{#1+0.5}\fi
but this does not work. Is this possible to do in plan tex/latex without external library?
EDIT: Since #1 is fortunately integer, this works \def\xa{#1.5}. However, what if I wanted to add 1.5?
\ifnum(and things like\numexpr) only deal in integers;\defdoes not perform arithmetic. – Steven B. Segletes Nov 06 '21 at 21:12#1is-5, then\xais not-5.5– Pygmalion Nov 06 '21 at 21:18#1is an integer, all you need is to append.5to\xaregardless of the sign. – Nov 06 '21 at 21:20.5) – user202729 Nov 07 '21 at 02:13