To use package{calc}
for calculation, number should not include any commas. So I tried to use \def\commatonone #1,#2.00 {#1#2}
to get the number without commas.
\documentclass{article}
\usepackage{calc}
\def\commatonone #1,#2.00 {#1#2}
\begin{document}
\commatonone 192,150.00
\end{document}
However, if I use command to define the number, error happens.
\documentclass{article}
\usepackage{calc}
\def\commatonone #1,#2.00 {#1#2}
\newcommand{\BASESALARYAMOUNT}{149,500.00}
\newcommand{\PREVIOUSBASESALARYAMOUNT}{110,000.00}
\begin{document}
\newcounter{BASESALARYDIFFERENCE}
\addtocounter{BASESALARYDIFFERENCE}{\commatonone\BASESALARYAMOUNT}
\addtocounter{BASESALARYDIFFERENCE}{\commatonone\PREVIOUSBASESALARYAMOUNT}
\end{document}
Error: Paragraph ended before \commatonone was complete. []
Are there any way to fix it? Or any better way to do the calculation with the number having commas already? (numbers are input from other files, so cannot change from raw data). And I hope it can be used for numbers like xxx.xx
, xxx,xxx.xx
, xxx,xxx,xxx.xx
etc.
\catcode`, 9
before the\input
(and\catcode44 12
after) could work, depending on the file contents. But you also have the issue of the decimal part.00
which can not be used, even withcalc
as is in a\addtocounter
. (this is why David's answer removes it)