A decimal number can always be input either with the comma or the period, when TeX's length tests are concerned.
On the other hand, the standard test for \ifthenelse
compares integer numbers. So we need to do differently:
\ifthenelse{\lengthtest{\a pt < 0pt}}{smaller}{not smaller}
will do, because \a
will expand to the decimal number and adding the unit point to it will give a legitimate length to be compared with 0pt
.
One is not forced to use 0pt
: any length is good. So if the test must compare if the given number is less than 1.23
,
\ifthenelse{\lengthtest{\a pt < 1.23pt}}{smaller}{not smaller}
will do. This, of course, will compare correctly numbers with a short decimal part (TeX compares correctly up to the fourth decimal digit, the fifth may not be recognized because of the internal binary arithmetic with truncation).
Either commas or periods for delimiting the decimal part can be used safely.
\ifthenelse
compares only integer numbers. You may try\ifthenelse{\lengthtest{\a pt<0pt}}{true}{false}
which should be indifferent to the decimal separator (comma or period). – egreg Nov 28 '12 at 11:55\lengthtest
seems to only work with,
for testing if\a
is larger/smaller than zero (not other values). But this is already very good. – Tim Nov 28 '12 at 12:16\lengthtest{\a pt<5pt}
. – Stephan Lehmke Nov 28 '12 at 12:46\ifdim \a pt<2,5pt x \else y \fi
(note thept
after the numbers to be tested). – Jake Nov 28 '12 at 12:48,
by.
. – yo' Nov 28 '12 at 12:50