% DecNum.sty % (copyleft) by Jan Jełowicki 2002--2003 % jasj@ozi.ar.wroc.pl % % formatuje liczby całkowite i dziesiętne: \decnum{12345678.90123} --> 12t345t678d90123 % gdzie t=\thous@ndsep@r@tor, d=\decim@lsep@r@tor % % \decim@lsep@r@tor trzyma posta/c separatora % \chardef\decim@lsep@r@tor=`. % % \defdecsep redefiniuje separator % \def\defdecsep#1{\chardef\decim@lsep@r@tor=`#1} % % \decsep umieszcza separator w tek/scie % \newcommand*{\decsep}{{\decim@lsep@r@tor}} % % \thous@ndsep@r@tor trzyma odst/ep mi/edzy tysi/ecznymi rz/edami wielko/sci \newcommand*\thous@ndsep@r@tor{\,} % % \thousep umieszcza ten odst/ep w tek/scie \def\thousep{\thous@ndsep@r@tor} % % \defthousep redefiniuje separator % \def\defthousep#1{\renewcommand*{\thous@ndsep@r@tor}{#1}} % % \defgroupwidth ustala obowi/azuj/ac/a szeroko/s/c grup cyfr (domy/slnie 3) \def\defgroupwidth#1{\thr@@=#1} % % liczniki robocze \newcounter{@ll} \newcounter{sepp@siti@n} % % \@ll oblicza d/lugo/s/c argumentu (tylko do testowania) \def\@ll#1{\setcounter{@ll}{0}\setcounter{sepp@siti@n}{0}\c@untch@rs#1\end\ifnum\value{sepp@siti@n}=0\setcounter{sepp@siti@n}{\value{@ll}}\else\fi} % % \c@untch@rs stanowi element p/etli zliczaj/acej \def\c@untch@rs#1{% \ifx#1.\def\ooo{\decsep}\setcounter{sepp@siti@n}{\value{@ll}}\else\def\ooo{#1}\fi \ifx#1\end \let\next=\relax\else \stepcounter{@ll}\let\next=\c@untch@rs \fi \next} % % liczniki robocze \newcount\thr@@\thr@@=3 \newcount\@aa % % \decnum przedstawia argument z u/zyciem obu wprowadzonych separator/ow % % \def\decnum#1{\ensuremath{\setcounter{@ll}{0}\setcounter{sepp@siti@n}{0}\c@untch@rs#1\end\ifnum\value{sepp@siti@n}=0\setcounter{sepp@siti@n}{\value{@ll}}\else\fi \gr@updecim@ls#1\end}} % % \gr@updecim@ls stanowi element p/etli grupuj/acej \def\gr@updecim@ls#1{% \ifx#1.\def\ooo{\decsep}\else\def\ooo{#1}\fi \ifx#1\end \let\next=\relax\else \addtocounter{sepp@siti@n}{-1}\ooo\ifnum\value{sepp@siti@n}>0 \@aa=\value{sepp@siti@n} \divide\@aa by\thr@@ \multiply\@aa by\thr@@ \ifnum\value{sepp@siti@n}=\@aa\thous@ndsep@r@tor\else\fi\fi\let\next=\gr@updecim@ls \fi \next} % % To tyle. % %