RNDWRS(R,NL)
$(RATIONAL NUMBER DECIMAL WRITE SPECIAL.R IS A RATIONAL NUMBER.NL IS A
NON-NEGATIVE INTEGER. R IS APPROXIMATED BY A DECIMAL FRACTION D WITH
NL DECIMAL DIGITS FOLLOWING THE DECIMAL POINT AND D IS WRITTEN IN THE
OUTPUT STREAM. THE INACCURACY OF THE APPROXIMATION IS AT MOST
(1/2)*10**-NL.)
SAFE B,DL,IL,SL,TL.
(1) $(COMPUTE APPROXIMATION.) IF R=0 THEN ( A=0. B=1 ) ELSE
FIRST2(R.A,B). SL=ISIGNF(A). IF SL LT 0 THEN A=INEG(A).
M=IEXP(10,NL). A=IPROD(A,M). IQR(A,B.D,F). F=IDPR(F,2).
IF F=0 THEN TL=0 ELSE ( TL=ICOMP(B,F). IF TL=0 THEN TL=1 ELSE
IF TL LT 0 THEN D=ISUM(D,1) ).
(2) $(CONVERT AND WRITE.) IF SL LT 0 THEN CWRITE($=-).
IQR(D,M.D,F). IWRITE(D). CWRITE($=.). FOR IL=1,...,NL DO
( F=IDPR(F,10). IQR(F,M.DL,F). CWRITE(DL) ). RETURN..