[comp.lang.postscript] Rounding errors in Postscript: How bad?

bb@beach.cis.ufl.edu (Brian Bartholomew) (12/28/89)

Exactly how bad are the problems with rounding errors in Postscript
programs?  I recognize that there are specific operators to deal with
this, like closepath, and I often see gsave/grestore used to save
nothing more than the current point.  Very recently, I was making a
Postscipt version of an RS-232 reference chart.  I started with a
monospaced ASCII version that had lines drawn with dashes and vertical
bars, and I intended to make this print first, then replace the ASCII
lines with real Postscript lines drawn on top of them.  The chart was
about 35 lines long, in 12 point Courier, and it was translated so that
each print line started at zero X.  To print each line of the chart, I
wrote a function (reproduced below) that would show the chart line, use
currentpoint to find out what the current Y value was, add some to it
to move downward, and do a moveto.  When I went back to draw my
vertical line over the first line of pipe characters, I noticed that
the bottom of the line of pipes was shifted about 3 points to the right
(?) of the top, relative to the line drawn from 0 0 to 0 -something.
Is this much inaccuracy to be expected?  Remember, before I showed a
line of text, I moved to 0 -something.  Or, is "0 72 mul" not really
*zero*?  This code was run into an Apple Laserwriter II NT.


	/inch { 72 mul } bind def
	
	/show&CR {	% args: (string to show)
		show
		currentpoint
		exch pop
		-0.16 inch add
		0 inch exch moveto
	} bind def


--
"Any sufficiently advanced technology is indistinguishable from a rigged demo."
-------------------------------------------------------------------------------
Brian Bartholomew	UUCP:       ...gatech!uflorida!beach.cis.ufl.edu!bb
University of Florida	Internet:   bb@beach.cis.ufl.edu