# How should I express my length calculation to minimize rounding errors?

I have an input file as follows.

% Test.tex
\documentclass{article}
\usepackage{pstricks}
\psset
{
linewidth=0.01
}

\newcommand\All{0.1}
\newcommand\Left{-\All}
\newcommand\Right{\All}
\newcommand\Bottom{-\All}
\newcommand\Top{\All}

\newlength\AllPadding\setlength{\AllPadding}{0mm}
\newlength\LeftPadding\setlength{\LeftPadding}{\AllPadding}
\newlength\RightPadding\setlength{\RightPadding}{\AllPadding}
\newlength\BottomPadding\setlength{\BottomPadding}{\AllPadding}
\newlength\TopPadding\setlength{\TopPadding}{\AllPadding}

\topmargin=\dimexpr\TopPadding-72.27pt\relax
\oddsidemargin=\dimexpr\LeftPadding-72.27pt\relax
\paperwidth=\dimexpr\Right\psxunit-\Left\psxunit+\RightPadding+\LeftPadding\relax
\paperheight=\dimexpr\Top\psyunit-\Bottom\psyunit+\TopPadding+\BottomPadding\relax

\special{papersize=\the\paperwidth,\the\paperheight}

\headheight=0pt
\headsep=0pt
\parindent=0pt
\topskip=0pt
\pagestyle{empty}

\pagecolor{yellow}
\begin{document}
\pspicture(\Left,\Bottom)(\Right,\Top)
\psframe(\Left,\Bottom)(\Right,\Top)
\endpspicture
\end{document}


It is compiled with the following batch file.

rem Automate.bat takes an input file name without extension.
latex %1
dvips %1
gswin32c -dNOPAUSE -dBATCH -sDEVICE=pdfwrite -sOutputFile=%1.pdf %1.ps
pdftops -eps %1.pdf


I got a result as follows.

Notice that there are excessive strips outside the black frame due to rounding errors in calculating paper size. Depending on the given settings, the excessive strips may appear on the left, right, top, and bottom. Even though the excessive strips will not be noticeable by naked eyes, I want to remove them as far as there is a way to do so.

How to express my length calculation to get rid of the excessive strips?

-
run it with xelatex and everything will be fine. – Herbert Jul 26 '11 at 20:39
+1 but XeLaTeX renders very slowly. I cannot use it for animating PSTricks diagrams. It takes too much time, even though for a simple series of object changes. – xport Jul 27 '11 at 0:05

## 1 Answer

dvips -D10000 %1 and gswin32c ... -r10000 ... will use more precision in your conversions. There will still be rounding error.

-