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

Re: Rounding problems



Matthias Clasen <clasen@mathematik.uni-freiburg.de> writes:

>> Going from vpl to vf and back reproduces the value 7.0, but TeX thinks
>> the value of the font dimension is 6.99998. This might be caused by
>> different internal representations for dimensions in vptovf/vftovp and
>> tex.

This one certainly bears investigating.  Don Knuth was exceedingly
careful to develop a decimal-binary conversion algorithm that never
loses bits in the transformation binary -> decimal -> binary.  The
definitive paper is:

@InCollection{Knuth:1990:SPW,
  author =       "Donald E. Knuth",
  title =        "A Simple Program Whose Proof Isn't",
  crossref =     "Feijen:1990:BOB",
  chapter =      "27",
  pages =        "233--242 (of xix + 453)",
  year =         "1990",
  bibdate =      "Sun Mar 27 17:53:57 1994",
  note =         "This paper discusses the algorithm used in {\TeX} for
                 converting between decimal and scaled fixed-point
                 binary values, and for guaranteeing a minimum number of
                 digits in the decimal representation. See also
                 \cite{Clinger:1990:HRF} for decimal to binary
                 conversion, \cite{Steele:1990:HPF} for binary to
                 decimal conversion, and \cite{Gries:1990:BDO} for an
                 alternate proof of Knuth's algorithm.",
  acknowledgement = ack-nhfb,
}

This appears in the book

@String{pub-SV                  = "Spring{\-}er-Ver{\-}lag"}

@String{pub-SV:adr              = "Berlin, Germany~/ Heidelberg,
                                  Germany~/ London, UK~/ New York, NY,
                                  USA, etc."}


@Book{Feijen:1990:BOB,
  editor =       "W. H. J. Feijen and A. J. M. van Gasteren and D. Gries
                 and J. Misra",
  booktitle =    "Beauty is our business: a birthday salute to {Edsger
                 W. Dijkstra}",
  title =        "Beauty is our business: a birthday salute to {Edsger
                 W. Dijkstra}",
  publisher =    pub-SV,
  address =      pub-SV:adr,
  pages =        "xix + 453",
  year =         "1990",
  ISBN =         "0-387-97299-4",
  LCCN =         "QA76 .B326 1990",
  bibdate =      "Thu Mar 24 09:27:40 1994",
  acknowledgement = ack-nhfb,
}

Here are the cross-referenced citations:

@String{j-SIGPLAN               = "SIGPLAN Notices"}


@Article{Clinger:1990:HRF,
  author =       "William D. Clinger",
  title =        "How to Read Floating Point Numbers Accurately",
  journal =      j-SIGPLAN,
  volume =       "25",
  number =       "6",
  pages =        "92--101",
  month =        jun,
  year =         "1990",
  CODEN =        "SINOD",
  ISSN =         "0362-1340",
  bibdate =      "Fri Aug 19 17:06:44 1994",
  note =         "See also output algorithm in \cite{Steele:1990:HPF}.",
  acknowledgement = ack-nhfb,
}

@Article{Steele:1990:HPF,
  author =       "Guy L. {Steele Jr.} and Jon L. White",
  title =        "How to Print Floating-Point Numbers Accurately",
  journal =      j-SIGPLAN,
  volume =       "25",
  number =       "6",
  pages =        "112--126",
  month =        jun,
  year =         "1990",
  CODEN =        "SINOD",
  ISSN =         "0362-1340",
  bibdate =      "Fri Aug 19 17:06:19 1994",
  note =         "See also input algorithm in \cite{Clinger:1990:HRF}.
                 In electronic mail dated Wed, 27 Jun 90 11:55:36 EDT,
                 Guy Steele reported that an intrepid pre-SIGPLAN 90
                 conference implementation of what is stated in the
                 paper revealed 3 mistakes: \begin{itemize} \item[1.]
                 Table~5 (page 124):\par\noindent insert {\tt k <-- 0}
                 after assertion, and also delete {\tt k <-- 0} from
                 Table~6. \item[2.] Table~9 (page 125):\par\noindent
                 \begin{tabular}{ll} for & {\tt -1:USER!({"}{"});} \\
                 substitute & {\tt -1:USER!({"}0{"});}
                 \end{tabular}\par\noindent and delete the comment.
                 \item[3.] Table~10 (page 125):\par\noindent
                 \begin{tabular}{ll} for & {\tt fill(-k, {"}0{"})}\\
                 substitute & {\tt fill(-k-1, {"}0{"})} \end{tabular}
                 \end{itemize}
                 \def\EatBibTeXPeriod#1{\ifx#1.\else#1\fi}\EatBibTeXPeriod",
  acknowledgement = ack-nhfb,
}

@InCollection{Gries:1990:BDO,
  author =       "David Gries",
  title =        "Binary to Decimal, One More Time",
  crossref =     "Feijen:1990:BOB",
  chapter =      "16",
  pages =        "141--148 (of xix + 453)",
  year =         "1990",
  bibdate =      "Sun Mar 27 17:53:57 1994",
  note =         "This paper presents an alternate proof of Knuth's
                 algorithm \cite{Knuth:1990:SPW} for conversion between
                 decimal and fixed-point binary numbers.",
  acknowledgement = ack-nhfb,
}

----------------------------------------------------------------------------
- Nelson H. F. Beebe                  Tel: +1 801 581 5254                 -
- Center for Scientific Computing     FAX: +1 801 581 4148                 -
- University of Utah                  Internet e-mail: beebe@math.utah.edu -
- Department of Mathematics, 105 JWB                   beebe@acm.org       -
- 155 S 1400 E RM 233                                  beebe@ieee.org      -
- Salt Lake City, UT 84112-0090, USA  URL: http://www.math.utah.edu/~beebe - 
----------------------------------------------------------------------------