[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Rounding problems




A complete example of rounding errors between vptovf and tex, and a solution.
The log files foo.log and bar.log have been generated by:

vptovf foo
tex foo
tex bar

Regards, Matthias


foo.vpl
-----------------
(DESIGNSIZE R 10.0)
(DESIGNUNITS R 10.0)
(CODINGSCHEME UNSPECIFIED)

(FONTDIMEN
   (PARAMETER D  1 R 0.1)
   (PARAMETER D  2 R 0.2)
   (PARAMETER D  3 R 0.3)
   (PARAMETER D  4 R 0.4)
   (PARAMETER D  5 R 0.5)
   (PARAMETER D  6 R 0.6)
   (PARAMETER D  7 R 0.7)
   (PARAMETER D  8 R 0.8)
   (PARAMETER D  9 R 0.9)
   (PARAMETER D 10 R 1.0)
   (PARAMETER D 11 R 1.1)
   (PARAMETER D 12 R 1.2)
   (PARAMETER D 13 R 1.3)
   (PARAMETER D 14 R 1.4)
   (PARAMETER D 15 R 1.5)
   (PARAMETER D 16 R 1.6)
   (PARAMETER D 17 R 1.7)
   (PARAMETER D 18 R 1.8)
   (PARAMETER D 19 R 1.9)
   (PARAMETER D 20 R 2.0)
   (PARAMETER D 21 R 2.1)
   (PARAMETER D 22 R 2.2)
   (PARAMETER D 23 R 2.3)
   (PARAMETER D 24 R 2.4)
   (PARAMETER D 25 R 2.5)
   (PARAMETER D 26 R 2.6)
   (PARAMETER D 27 R 2.7)
   (PARAMETER D 28 R 2.8)
   (PARAMETER D 29 R 2.9)
   (PARAMETER D 30 R 3.0)
   )
-------------------

foo.tex
-------------------
\font\foo=foo
\def\do#1{\message{\the\fontdimen#1\foo}}
\do{1} \do{2} \do{3} \do{4} \do{5} \do{6} \do{7} \do{8} \do{9} \do{10}
\do{11}\do{12}\do{13}\do{14}\do{15}\do{16}\do{17}\do{18}\do{19}\do{20}
\do{21}\do{22}\do{23}\do{24}\do{25}\do{26}\do{27}\do{28}\do{29}\do{30}
\bye
-------------------

foo.log
-------------------
This is e-TeX, Version 3.14159-1.1 (Web2c 7.0) (format=tex 97.8.8)  17 OCT 1997 18:38
entering compatibility mode
**foo
(foo.tex
Babel <v3.6h> and hyphenation patterns for american, german, loaded.
0.09999pt 0.2pt 0.29999pt 0.4pt 0.5pt 0.59999pt 0.7pt 0.79999pt 0.9pt 1.0pt
1.09999pt 1.2pt 1.29999pt 1.4pt 1.49998pt 1.59999pt 1.7pt 1.8pt 1.9pt
1.99998pt 2.09999pt 2.2pt 2.3pt 2.4pt 2.5pt 2.59999pt 2.7pt 2.79999pt 2.9pt
3.0pt )
No pages of output.
---------------------

bar.tex
---------------------
\font\foo=foo

% a micro LaTeX setup
\catcode`\@=11  
\newdimen\dimen@ 
\newcount\count@ 
\newcount\@tempcnta 
\newcount\@tempcntb
\chardef\@ne=1 
\mathchardef\@m=1000

\def\round@{\multiply\dimen@\@m \expandafter\round@@\the\dimen@}
\begingroup
  \catcode`T=12
  \lowercase{
\gdef\round@@#1.{\@tempcnta#1 \round@@@}
\gdef\round@@@#1#2T{
 \ifnum#1>4 \advance\@tempcnta\@ne \fi
 \@tempcntb\@tempcnta \divide\@tempcntb\@m
 \count@\@tempcntb \multiply\count@\@m
 \advance\@tempcnta-\count@
  \def\pp{\the\@tempcntb.\the\@tempcnta pt}
  \expandafter\dimen@\pp}
}
\endgroup

\def\do#1{\dimen@\fontdimen#1\foo \round@ \message{\the\dimen@}}

\do{1} \do{2} \do{3} \do{4} \do{5} \do{6} \do{7} \do{8} \do{9} \do{10}
\do{11}\do{12}\do{13}\do{14}\do{15}\do{16}\do{17}\do{18}\do{19}\do{20}
\do{21}\do{22}\do{23}\do{24}\do{25}\do{26}\do{27}\do{28}\do{29}\do{30}

\bye
------------------

bar.log
------------------
This is e-TeX, Version 3.14159-1.1 (Web2c 7.0) (format=tex 97.8.8)  17 OCT 1997 20:53
entering compatibility mode
**bar
(bar.tex
Babel <v3.6h> and hyphenation patterns for american, german, loaded.
\dimen@=\dimen16
\count@=\count26
\@tempcnta=\count27
\@tempcntb=\count28
0.1pt 0.2pt 0.3pt 0.4pt 0.5pt 0.6pt 0.7pt 0.8pt 0.9pt 1.0pt 1.1pt 1.2pt 1.3pt
1.4pt 1.5pt 1.6pt 1.7pt 1.8pt 1.9pt 2.0pt 2.1pt 2.2pt 2.3pt 2.4pt 2.5pt 2.6pt
2.7pt 2.8pt 2.9pt 3.0pt )
No pages of output.