%%
%% This is file `makebase.sty',
%% generated with the docstrip utility.
%%
%% The original source files were:
%%
%% makebase.dtx  (with options: `package')
%% This file was generated from an XML master source.
%% Amendments and corrections should be notified to the
%% maintainer for inclusion in future versions.
\NeedsTeXFormat{LaTeX2e}[2014/09/29]
\ProvidesPackage{makebase}[2016/05/10 v0.2
 Typeset counters in a different base]
%%
%% Packages required
%%
%% Required for calculations involving lengths or counters, such as changes to widths for margin adjustment.
\RequirePackage{calc}
\newcounter{Sil@MB@prenum}
\newcounter{Sil@MB@postnum}
\newcounter{Sil@MB@quot}
\newcounter{Sil@MB@rem}
\newcounter{Sil@MB@div}
\newcommand{\Sil@MB@maxdiv}[2][16]{%
  \setcounter{Sil@MB@div}{#1}%
  \setcounter{Sil@MB@prenum}{#2}%
  \loop
    \divide\c@Sil@MB@prenum by\c@Sil@MB@div
    \multiply\c@Sil@MB@prenum by\c@Sil@MB@div
    \multiply\c@Sil@MB@div by#1
    \ifnum\c@Sil@MB@prenum>0
  \repeat
  \divide\c@Sil@MB@div by#1
  \divide\c@Sil@MB@div by#1
}
\newcommand{\makebase}[2][16]{%
  \Sil@MB@maxdiv[#1]{#2}%
  \ifnum#1=16 0x\else\ifnum#1=8 0\fi\fi
  \setcounter{Sil@MB@prenum}{#2}%
  \setcounter{Sil@MB@postnum}{#2}%
  \loop
    \ifnum\c@Sil@MB@div>\c@Sil@MB@prenum
      0\divide\c@Sil@MB@div by#1
    \fi
    \divide\c@Sil@MB@postnum by\c@Sil@MB@div
    \setcounter{Sil@MB@quot}{\value{Sil@MB@postnum}}%
    \multiply\c@Sil@MB@postnum by\c@Sil@MB@div
    \setcounter{Sil@MB@rem}{\value{Sil@MB@prenum}-\value{Sil@MB@postnum}}%
    \ifcase\c@Sil@MB@quot 0\or 1\or 2\or 3\or 4\or 5\or 6\or
           7\or 8\or 9\or A\or B\or C\or D\or E\or F\else !Z\fi
    \setcounter{Sil@MB@prenum}{\value{Sil@MB@rem}}%
    \setcounter{Sil@MB@postnum}{\value{Sil@MB@rem}}%
    \divide\c@Sil@MB@div by#1
    \ifnum\c@Sil@MB@rem>0
  \repeat
}

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