%%
%% This is file `numprint032.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% numprint032.dtx  (with options: `package')
%% 
%%   numprint package
%% 
%%   Copyright  2000--2005 Harald Harders
%% 
%%   This program can be redistributed and/or modified under the terms
%%   of the LaTeX Project Public License Distributed from CTAN
%%   archives in directory macros/latex/base/lppl.txt; either
%%   version 1 of the License, or any later version.
%% 
%%   h.harders@tu-bs.de
%% 
\def\packagename{numprint}
\def\nprtfileversion{0.32}
\def\nprtfiledate{2003/09/18}
\def\nprtdocdate{2003/09/18}
\NeedsTeXFormat{LaTeX2e}
\ProvidesPackage{numprint032}[\nprtfiledate\space v\nprtfileversion\space
  Print numbers]
\message{Package `numprint032', Version \nprtfileversion\space of \nprtfiledate.}
\message{Compatiblity version of numprint for versions prior 1.00}
\RequirePackage{calc}
\RequirePackage{array}
\newif\if@numsepfour
\newcommand\@addmissingzero{}
\newcommand*{\fourdigitsep}{\@numsepfourtrue}%
\newcommand*{\fourdigitnosep}{\@numsepfourfalse}%
\newcommand*{\addmissingzero}{\def\@addmissingzero{0}}%
\newcommand*{\noaddmissingzero}{\def\@addmissingzero{}}%
\DeclareOption{nosepfour}{\fourdigitnosep}
\DeclareOption{sepfour}{\fourdigitsep}
\DeclareOption{noaddmissingzero}{\noaddmissingzero}
\DeclareOption{addmissingzero}{\addmissingzero}
\ExecuteOptions{sepfour,addmissingzero}
\ProcessOptions\relax
\newcommand{\npdecimalsign}[1]{\def\nprt@decimal{{#1}}}
\newcommand{\npthousandsep}[1]{\def\nprt@thousand{{#1}}%
  \def\nprt@thousandthpart{{#1}}}
\newcommand{\npthousandthpartsep}[1]{\def\nprt@thousandthpart{{#1}}}
\newcommand{\npproductsign}[1]{\def\nprt@prod{\ensuremath{{}#1{}}}}
\newcommand{\npunitseparator}[1]{\def\nprt@unitsep{{#1}}}
\npthousandsep{\,}%
\npthousandthpartsep{\,}%
\npdecimalsign{,}%
\npproductsign{{}\cdot{}}%
\npunitseparator{\,}%
\def\@fillnull#1#2{%
  \@tempcnta=0
  \loop
    \g@addto@macro{#1}{0}%
    \advance\@tempcnta by 1
  \ifnum\@tempcnta<#2
  \repeat
}
\newcommand\nprounddigits[1]{%
  \def\nprt@rounddigits{#1}%
  \def\nprt@roundnull{}%
  \@fillnull{\nprt@roundnull}{#1}%
}
\newcommand\npnoround{\nprounddigits{-1}}
\npnoround
\newcommand\nproundexpdigits[1]{%
  \def\nprt@roundexpdigits{#1}%
  \def\nprt@roundexpnull{}%
  \@fillnull{\nprt@roundexpnull}{#1}%
  }
\newcommand\npnoroundexp{\nproundexpdigits{-1}}
\npnoroundexp
\newcommand\npreplacenull[1]{\def\nprt@replacenull{#1}}
\newcommand\npprintnull{\let\nprt@replacenull=\@empty}
\npprintnull
\def\nprt@plus@test{+}
\def\nprt@minus@test{-}
\def\nprt@plusminus@test{\pm}
\def\nprt@plus{\ensuremath{+}}
\def\nprt@minus{\ensuremath{-}}
\def\nprt@plusminus{\ensuremath{\pm}}
\def\nprt@printdigit#1{%
  \def\nprt@tmp{#1}%
  \ifx\nprt@tmp\nprt@plus@test
    \nprt@plus
  \else
    \ifx\nprt@tmp\nprt@minus@test
      \nprt@minus
    \else
      \ifx\nprt@tmp\nprt@plusminus@test
        \nprt@plusminus
      \else
        #1%
      \fi
    \fi
  \fi
}
\newif\ifnprt@block
\newif\ifnprt@blockexp
\newif\ifnprt@exponent
\newif\ifnprt@inmath
\newcommand{\digits}[2]{%
  \xdef\nprt@blockbefore{#1}%
  \xdef\nprt@blockafter{#2}%
  \nprt@blocktrue}%
\newcommand{\nodigits}{\nprt@blockfalse}%
\newcommand{\exponentdigits}[1]{%
  \xdef\nprt@blockexpbefore{#1}%
  \nprt@blockexptrue}%
\newcommand{\noexponentdigits}{\nprt@blockexpfalse}%
\def\nprt@three#1#2#3#4\@empty{%
  \nprt@printdigit#1%
  \nprt@printdigit#2%
  \nprt@printdigit#3%
  \def\nprt@tmp{#4}%
  \ifx\nprt@tmp\empty
  \else
    \nprt@thousand%
    \nprt@three#4\@empty\@empty\@empty
  \fi
}
\def\nprt@threeafter#1#2#3#4\@empty{%
  \nprt@printdigit#1%
  \nprt@printdigit#2%
  \nprt@printdigit#3%
  \def\nprt@tmp{#4}%
  \ifx\nprt@tmp\empty
  \else
    \nprt@thousandthpart%
    \nprt@threeafter#4\@empty\@empty\@empty
  \fi
}
\def\nprt@two#1#2#3\@empty{%
  \nprt@printdigit#1%
  \nprt@printdigit#2%
  \def\nprt@tmp{#3}%
  \ifx\nprt@tmp\empty
  \else
    \nprt@thousand\nprt@three#3\@empty\@empty\@empty
  \fi
}
\def\nprt@one#1#2\@empty{%
  \nprt@printdigit#1%
  \def\nprt@tmp{#2}%
  \ifx\nprt@tmp\empty
  \else
    \def\nprt@tmp{#1}%
    \ifx\nprt@tmp\nprt@plus@test
    \else
      \ifx\nprt@tmp\nprt@minus@test
      \else
        \ifx\nprt@tmp\nprt@plusminus@test
        \else
          \nprt@thousand
        \fi
      \fi
    \fi
    \nprt@three#2\@empty\@empty\@empty
  \fi
}
\def\nprt@exptest#1e#2\@empty{\gdef\nprt@tmp{#2}}
\def\nprt@Exptest#1E#2\@empty{\gdef\nprt@tmp{#2}}
\def\nprt@commatest#1,#2\@empty{\gdef\nprt@tmp{#2}}
\def\nprt@dottest#1.#2\@empty{\gdef\nprt@tmp{#2}}
\def\nprt@exp#1e#2\@empty{\expnumprint{#1}{#2}}
\def\nprt@Exp#1E#2\@empty{\expnumprint{#1}{#2}}
\def\nprt@comma#1,#2\@empty{%
  \nprt@dotcomma{#1}{#2}}
\def\nprt@dot#1.#2\@empty{%
  \nprt@dotcomma{#1}{#2}}
\def\nprt@dotcomma#1#2{%
  \begingroup
  \ifnprt@exponent
    \edef\nprt@rounddigits{\nprt@roundexpdigits}%
    \edef\nprt@roundnull{\nprt@roundexpnull}%
  \fi
  \ifnum\nprt@rounddigits<0
    \def\nprt@charsbeforecomma{#1}%
    \def\nprt@charsaftercomma{#2}%
  \else
    \def\nprt@charsbeforecomma{}%
    \def\nprt@charsaftercomma{}%
    \edef\zwei{#2\nprt@roundnull}%
    \expandafter\nprt@roundaftercomma\zwei\empty
    \if@@roundup
      \nprt@roundbeforecomma#1\empty
      \if@@roundup
        \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
          1\nprt@charsbeforecomma}%
      \fi
    \else
      \def\nprt@charsbeforecomma{#1}%
    \fi
  \fi
  \nprt@@hassignfalse
  \expandafter\nprt@count\nprt@charsaftercomma\@empty\@empty\@empty
  \setcounter{nprt@digitsafterdecimal}{\thenprt@digitsbeforedecimal}%
  \expandafter\nprt@hassign\nprt@charsbeforecomma\@empty\@empty
  \expandafter\nprt@count\nprt@charsbeforecomma\@empty\@empty\@empty
  \ifnum\the\c@nprt@digitsbeforedecimal=0
    \@addmissingzero
  \else
    \expandafter\beforecomma\nprt@charsbeforecomma\@empty\@empty
  \fi
  \ifnum\nprt@rounddigits=0
  \else
    \nprt@decimal
    \ifnum\the\c@nprt@digitsafterdecimal>0
      \aftercomma{\nprt@charsaftercomma}%
    \else
      \ifx\nprt@replacenull\@empty
        \@addmissingzero
      \else
        \nprt@replacenull
      \fi
    \fi
  \fi
  \endgroup
}
\newcommand{\expnumprint}[2]{%
  \def\nprt@tmp{#1}%
  \ifx\nprt@tmp\@empty
    \nprt@exponenttrue
    \ifmmode
      10^{\numprint{#2}}%
    \else
      10\textsuperscript{\numprint{#2}}%
    \fi
  \else
    \ifmmode
      \numprint{#1}%
      \nprt@exponenttrue
      \nprt@prod 10^{\numprint{#2}}%
    \else
      \numprint{#1}%
      \nprt@exponenttrue
      \nprt@prod 10\textsuperscript{\numprint{#2}}%
    \fi
  \fi
  \nprt@exponentfalse
}
\def\nprt@empty{\@empty}%
\DeclareRobustCommand*\numprint[2][\@empty]{%
  \setcounter{nprt@digitsafterdecimal}{0}%
  \setcounter{nprt@digitsbeforedecimal}{0}%
  \edef\nprt@marg{#2}%
  \expandafter\nprt@Exptest\nprt@marg E\@empty
  \ifx\nprt@tmp\empty
    \expandafter\nprt@exptest\nprt@marg e\@empty
    \ifx\nprt@tmp\empty
      \expandafter\nprt@commatest\nprt@marg,\@empty
      \ifx\nprt@tmp\empty
        \expandafter\nprt@dottest\nprt@marg.\@empty
        \ifx\nprt@tmp\empty
          \expandafter\nprt@hassign\nprt@marg\@empty
          \expandafter\nprt@count\nprt@marg\@empty\@empty\@empty
          \begingroup
          \ifnprt@exponent
            \def\nprt@rounddigits{\nprt@roundexpdigits}%
            \def\nprt@roundnull{\nprt@roundexpnull}%
          \fi
          \ifnum\nprt@rounddigits>0
            \setcounter{nprt@digitsafterdecimal}{\nprt@rounddigits}%
          \fi
          \expandafter\beforecomma\nprt@marg\@empty\@empty
          \ifnum\nprt@rounddigits>0
            \nprt@decimal
            \aftercomma{\nprt@roundnull}%
          \fi
          \endgroup
        \else
          \expandafter\nprt@dot\nprt@marg\@empty
        \fi
      \else
        \expandafter\nprt@comma\nprt@marg\@empty
      \fi
    \else
      \expandafter\nprt@exp\nprt@marg\@empty
    \fi
  \else
    \expandafter\nprt@Exp\nprt@marg\@empty
  \fi
  \def\nprt@unit{#1}%
  \ifx\nprt@unit\nprt@empty
  \else
    \ensuremath{\nprt@unitsep\mathrm{\nprt@unit}}%
  \fi
}
\newcounter{nprt@countblocksbefore}%
\newcounter{nprt@digitsfirstblock}%
\newcounter{nprt@digitsafterdecimal}%
\newcounter{nprt@digitsbeforedecimal}%
\newif\ifnprt@@hassign
\def\nprt@hassign#1#2\@empty{%
  \ifnum-9>-1#1
    \nprt@@hassignfalse
  \else
    \nprt@@hassigntrue
  \fi
}
\def\nprt@count#1#2\@empty{%
  \setcounter{nprt@digitsbeforedecimal}{0}%
  \edef\nprt@arg{#1}%
  \ifx\nprt@arg\@empty
  \else
    \ifnprt@@hassign
      \nprt@@count#2\@empty\@empty
    \else
      \nprt@@count#1#2\@empty\@empty
    \fi
  \fi
  \setcounter{nprt@countblocksbefore}{\arabic{nprt@digitsbeforedecimal}/3}%
  \setcounter{nprt@digitsfirstblock}{%
    \arabic{nprt@digitsbeforedecimal}-3*\arabic{nprt@countblocksbefore}}%
}
\def\nprt@@count#1#2\@empty{%
  \ifnum-9>-1#1
    \addtocounter{nprt@digitsbeforedecimal}{1}%
    \def\nprt@tmp{#2}%
    \ifx\nprt@tmp\empty
    \else
      \nprt@@count#2\@empty\@empty
    \fi
  \else
    \PackageError{numprint}{Incorrect number format in
      \string\numprint}{%
      The main argument of the \string\numprint\space command may only
      be started\MessageBreak
      with \string"+\string", \string"-\string", or
      \string"\string\pm\string" and then contain of\MessageBreak
      digits \string"0\string" to \string"9\string",
      \string",\string", \string".\string", \string"e\string", and
      \string"E\string".}%
  \fi
}
\newlength{\nprt@digitwidth}%
\newlength{\nprt@sepwidth}%
\newcounter{nprt@digitcount}%
\newcounter{nprt@sepcount}%
\newlength{\nprt@blockwidth}%
\def\beforecomma#1#2\@empty{%
  \ifnprt@block
    \ifnprt@exponent
    \else
      \settowidth{\nprt@digitwidth}{1}%
      \settowidth{\nprt@sepwidth}{\nprt@thousand}%
      \setcounter{nprt@digitcount}{\nprt@blockbefore}%
      \setcounter{nprt@sepcount}{(\nprt@blockbefore-1)/3}%
      \setlength{\nprt@blockwidth}{%
        \arabic{nprt@digitcount}\nprt@digitwidth+%
        \arabic{nprt@sepcount}\nprt@sepwidth}%
      \if@numsepfour
      \else
        \ifnum\nprt@blockbefore=4
          \ifnum\nprt@blockafter<5
            \setlength{\nprt@blockwidth}{4\nprt@digitwidth}%
          \fi
        \fi
      \fi
      \ifmmode\nprt@inmathtrue\fi
      \makebox[\nprt@blockwidth][r]{%
      \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
    \fi
  \fi
  \ifnprt@blockexp
    \ifnprt@exponent
      \settowidth{\nprt@digitwidth}{1}%
      \settowidth{\nprt@sepwidth}{\nprt@thousand}%
      \setcounter{nprt@digitcount}{\nprt@blockexpbefore}%
      \setcounter{nprt@sepcount}{(\nprt@blockexpbefore-1)/3}%
      \setlength{\nprt@blockwidth}{%
        \arabic{nprt@digitcount}\nprt@digitwidth+%
        \arabic{nprt@sepcount}\nprt@sepwidth}%
      \if@numsepfour
      \else
        \ifnum\nprt@blockexpbefore=4
          \setlength{\nprt@blockwidth}{4\nprt@digitwidth}%
        \fi
      \fi
      \ifmmode\nprt@inmathtrue\fi
      \makebox[\nprt@blockwidth][r]{%
      \ifnprt@inmath$\scriptstyle\fi %$ (only for syntax highlighing in emacs)
    \fi
  \fi
  \ifnprt@@hassign
    \nprt@printdigit{#1}%
    \edef\nprt@tmp{#2}%
  \else
    \edef\nprt@tmp{#1#2}%
  \fi
  \ifnum\thenprt@digitsfirstblock=1
    \ifnum\thenprt@digitsbeforedecimal=4
      \if@numsepfour
        \expandafter\nprt@one\nprt@tmp\@empty\@empty\@empty
      \else
        \ifnum\thenprt@digitsafterdecimal<5
          \nprt@tmp\ignorespaces
        \else
          \expandafter\nprt@one\nprt@tmp\@empty\@empty\@empty
        \fi
      \fi
    \else
      \expandafter\nprt@one\nprt@tmp\@empty\@empty\@empty
    \fi
  \fi
  \ifnum\thenprt@digitsfirstblock=2
    \expandafter\nprt@two\nprt@tmp\@empty\@empty\@empty
  \fi
  \ifnum\thenprt@digitsfirstblock=0
    \expandafter\nprt@three\nprt@tmp\@empty\@empty\@empty\@empty
  \fi
  \ifnprt@blockexp
    \ifnprt@exponent
      \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
      }%
    \fi
  \fi
  \ifnprt@block
    \ifnprt@exponent
    \else
      \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
      }%
    \fi
  \fi
}
\newcommand{\aftercomma}[1]{%
  \ifnprt@block
    \ifnprt@exponent
    \else
      \settowidth{\nprt@digitwidth}{1}%
      \settowidth{\nprt@sepwidth}{\nprt@thousand}%
      \setcounter{nprt@digitcount}{\nprt@blockafter}%
      \setcounter{nprt@sepcount}{(\nprt@blockafter-1)/3}%
      \setlength{\nprt@blockwidth}{%
        \arabic{nprt@digitcount}\nprt@digitwidth+%
        \arabic{nprt@sepcount}\nprt@sepwidth}%
      \if@numsepfour
      \else
        \ifnum\nprt@blockafter=4
          \ifnum\nprt@blockbefore<5
            \setlength{\nprt@blockwidth}{4\nprt@digitwidth}%
          \fi
        \fi
      \fi
      \ifmmode\nprt@inmathtrue\fi
      \makebox[\nprt@blockwidth][l]{%
      \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
    \fi
  \fi
  \ifx\nprt@replacenull\@empty
  \else
    \ifnum#1=0
      \setcounter{nprt@digitsafterdecimal}{0}%
    \fi
  \fi
  \ifnum\thenprt@digitsafterdecimal=4
    \if@numsepfour
      \expandafter\nprt@threeafter#1\@empty\@empty\@empty
    \else
      \ifnum\thenprt@digitsbeforedecimal<5
        #1\ignorespaces
      \else
        \expandafter\nprt@threeafter#1\@empty\@empty\@empty
      \fi
    \fi
  \else
    \ifx\nprt@replacenull\@empty
      \expandafter\nprt@threeafter#1\@empty\@empty\@empty
    \else
      \ifnum#1=0
        \nprt@replacenull
      \else
        \expandafter\nprt@threeafter#1\@empty\@empty\@empty
      \fi
    \fi
  \fi
  \ifnprt@block
    \ifnprt@exponent
    \else
      \ifnprt@inmath$\fi %$ (only for syntax highlighing in emacs)
      }%
    \fi
  \fi
}
\newcounter{nprt@position}
\newif\if@@roundup
\newcounter{nprt@thisdigit}
\def\nprt@roundaftercomma#1#2\empty{%
  \addtocounter{nprt@position}{1}%
  \edef\zwei{#2}%
  \ifx\zwei\empty
  \else
    \expandafter\ifnum\thenprt@position<\nprt@rounddigits
      \nprt@roundaftercomma#2\empty
    \else
      \nprt@roundup#2\empty
    \fi
  \fi
  \setcounter{nprt@thisdigit}{#1}%
  \if@@roundup
    \addtocounter{nprt@thisdigit}{1}%
    \ifnum\thenprt@thisdigit>9
      \@@rounduptrue
      \setcounter{nprt@thisdigit}{0}%
    \else
      \@@roundupfalse
    \fi
  \fi
  \expandafter\xdef\expandafter\nprt@charsaftercomma{%
    \thenprt@thisdigit\nprt@charsaftercomma}%
  \addtocounter{nprt@position}{-1}%
}
\def\nprt@roundup#1#2\empty{%
  \ifnum#1>4
    \@@rounduptrue
  \else
    \@@roundupfalse
  \fi
}
\def\nprt@roundbeforecomma#1#2\empty{%
  \edef\zwei{#2}%
  \ifx\zwei\empty
  \else
    \nprt@roundbeforecomma#2\empty
  \fi
  \edef\eins{#1}%
  \ifnum-9>-1#1
    \setcounter{nprt@thisdigit}{#1}%
    \if@@roundup
      \addtocounter{nprt@thisdigit}{1}%
      \ifnum\thenprt@thisdigit>9
        \@@rounduptrue
        \setcounter{nprt@thisdigit}{0}%
      \else
        \@@roundupfalse
      \fi
    \fi
    \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
      \thenprt@thisdigit\nprt@charsbeforecomma}%
  \else
    \if@@roundup
      \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
        1\nprt@charsbeforecomma}%
      \@@roundupfalse
    \fi
    \expandafter\xdef\expandafter\nprt@charsbeforecomma{%
      #1\nprt@charsbeforecomma}%
  \fi
}
\newcolumntype{n}[2]{>{\digits{#1}{#2}$}l<{$\nodigits}}
\newcolumntype{N}[3]{%
  >{\digits{#1}{#2}\exponentdigits{#3}$}l<{$\nodigits\noexponentdigits}}

\endinput
%%
%% End of file `numprint032.sty'.
