Trailing-Edge
-
PDP-10 Archives
-
decuslib10-08
-
43,50476/dashow.for
There are 2 other files named dashow.for in the archive. Click here to see a list.
SUBROUTINE DASHOW(KONTRL,MINDEC,MAXDEC,MINSIG,MAXSIG,
1 IDECML,IVALUE,VALUE ,MAXBFR,KOUNT ,IBUFFR,IERR )
C RENBR(/REPRESENT INTEGER OR REAL NUMBER)
C
C DONALD BARTH, HARVARD BUSINESS SCHOOL
C
C ROUTINE TO REPRESENT INTEGERS OR REAL NUMBERS LEFT
C JUSTIFIED AND WITHOUT EXTRA RIGHTMOST BLANKS
C
C FOLLOWING ARGUMENTS ARE USED ONLY FOR INPUT AND ARE
C RETURNED UNCHANGED.
C
C KONTRL = -1, REPRESENT INTEGER VALUE INPUT AS
C ARGUMENT NAMED IVALUE AS OCTAL NUMBER.
C = 0, REPRESENT INTEGER VALUE INPUT AS ARGUMENT
C NAMED IVALUE AS DECIMAL NUMBER.
C = 1 OR GREATER, REPRESENT REAL VALUE INPUT AS
C ARGUMENT NAMED VALUE WITH NO MORE THAN
C MAXDEC NOR LESS THAN MINDEC DIGITS TO RIGHT
C OF DECIMAL POINT AND WITH NO MORE THAN
C MAXSIG NOR LESS THAN MINSIG SIGNIFICANT
C DIGITS. IF VALUE CANNOT BE REPRESENTED
C USING SPECIFIED NUMBERS OF DIGITS IN
C FLOATING POINT FORM (WITHOUT E EXPONENT),
C THEN VALUE IS INSTEAD REPRESENTED IN
C SCIENTIFIC NOTATION (WITH E EXPONENT) AND
C WITH IDECML DIGITS TO RIGHT OF DECIMAL POINT
C IN REPRESENTATION OF VALUE WHICH EITHER HAS
C VALUE ZERO, OR WHICH HAS BEEN MODIFIED
C THOUGH MULTIPLICATION BY POWER OF TEN SO AS
C TO FALL WITHIN RANGE 1.0 THROUGH 9.999...
C MINDEC = 0, THERE IS NO LOWER LIMIT TO NUMBER OF
C DIGITS WHICH MUST BE SHOWN TO RIGHT OF
C DECIMAL POINT OF NUMBER REPRESENTED IN
C FLOATING POINT FORM.
C = GREATER THAN ZERO, MINDEC IS MINIMUM NUMBER
C OF DIGITS WHICH CAN BE SHOWN TO RIGHT OF
C DECIMAL POINT OF NUMBER REPRESENTED IN
C FLOATING POINT FORM IF RIGHTMOST OF THESE
C DIGITS IS NONZERO. IF IT WOULD NOT BE
C POSSIBLE TO INCLUDE AT LEAST THIS NUMBER OF
C DIGITS TO RIGHT OF DECIMAL POINT, THEN VALUE
C WILL BE REPRESENTED IN SCIENTIFIC NOTATION
C INSTEAD. AFTER DETERMINING THAT IT WOULD BE
C POSSIBLE TO REPRESENT AT LEAST MINDEC DIGITS
C TO RIGHT OF DECIMAL POINT, THEN EACH DIGIT
C WHICH IS TO RIGHT OF DECIMAL POINT AND WHICH
C DOES NOT HAVE NONZERO DIGIT TO ITS RIGHT IS
C SUPPRESSED AND EVEN DECIMAL POINT WILL NOT
C BE SHOWN IF THERE ARE NO NONZERO DIGITS TO
C RIGHT OF DECIMAL POINT.
C MAXDEC = 0, REPRESENT ONLY DIGITS WHICH ARE TO LEFT
C OF DECIMAL POINT OF NUMBER REPRESENTED IN
C FLOATING POINT FORM.
C = GREATER THAN ZERO, MAXDEC IS MAXIMUM NUMBER
C OF DIGITS WHICH CAN BE SHOWN TO RIGHT OF
C DECIMAL POINT OF NUMBER REPRESENTED IN
C FLOATING POINT FORM.
C MINSIG = MINIMUM NUMBER OF SIGNIFICANT DIGITS WHICH
C CAN BE SHOWN IN NUMBER REPRESENTED IN
C FLOATING POINT FORM IF RIGHTMOST OF THESE
C DIGITS IS NONZERO. IF VALUE BEING DISPLAYED
C HAS VALUE ZERO, THEN MINSIG IS IGNORED.
C MAXSIG = 0, REPRESENT VALUE INPUT AS ARGUMENT NAMED
C VALUE IN SCIENTIFIC NOTATION (WITH E
C EXPONENT).
C = GREATER THAN ZERO, MAXSIG IS MAXIMUM NUMBER
C OF DIGITS WHICH CAN BE SHOWN IN NUMBER
C REPRESENTED IN FLOATING POINT FORM, STARTING
C WITH LEFTMOST NONZERO DIGIT, COUNTING IT AND
C ALL DIGITS TO ITS RIGHT. NUMBER OF DIGITS
C DISPLAYED TO RIGHT OF DECIMAL POINT IS
C REDUCED IF NECESSARY SO THAT NUMBER OF
C DIGITS STARTING AT LEFTMOST NONZERO
C DISPLAYED DIGIT AND COUNTING IT AND ALL
C DIGITS DISPLAYED TO ITS RIGHT DOES NOT
C EXCEED MAXSIG. IF MAXSIG WOULD BE LESS THAN
C NUMBER OF DIGITS LEFT OF DECIMAL POINT IN
C REPRESENTATION OF VALUE, THEN VALUE WILL BE
C REPRESENTED IN SCIENTIFIC NOTATION.
C IDECML = SAME AS MAXDEC EXCEPT THAT IDECML APPLIES
C ONLY TO VALUES DISPLAYED IN SCIENTIFIC
C NOTATION. NOTE THAT IF VALUE IS BEING
C REPRESENTED IN SCIENTIFIC NOTATION, THEN
C NONZERO DIGIT WILL BE USED LEFT OF DECIMAL
C POINT UNLESS VALUE IS ITSELF ZERO.
C THEREFORE, MAXIMUM NUMBER OF SIGNIFICANT
C DIGITS WHICH CAN BE DISPLAYED IN SCIENTIFIC
C NOTATION IS IDECML+1.
C IVALUE = INPUT CONTAINING INTEGER VALUE TO BE
C REPRESENTED IF KONTRL IS LESS THAN OR EQUAL
C TO ZERO.
C VALUE = INPUT CONTAINING REAL VALUE TO BE
C REPRESENTED IF KONTRL IS GREATER THAN ZERO.
C MAXBFR = SUBSCRIPT OF RIGHTMOST LOCATION IN IBUFFR
C ARRAY WHICH CAN BE USED BY THIS ROUTINE FOR
C RETURN OF CHARACTERS IN REPRESENTATION OF
C NUMBER. REPRESENTATION OF NUMBER WILL USE
C FEWER LOCATIONS IN IBUFFR ARRAY IF POSSIBLE.
C
C FOLLOWING ARGUMENT IS USED FOR BOTH INPUT AND OUTPUT.
C
C KOUNT = INPUT CONTAINING SUBSCRIPT OF RIGHTMOST
C (HIGHEST SUBSCRIPT VALUE) IBUFFR ARRAY
C LOCATION WHICH IS CURRENTLY IN USE AND WHICH
C MUST BE PRESERVED. REPRESENTATION OF NUMBER
C WILL BE RETURNED STARTING IN IBUFFR(KOUNT+1)
C AND EXTENDING THROUGH IBUFFR(MAXBFR) IF
C NECESSARY.
C = RETURNED CONTAINING SUBSCRIPT OF RIGHTMOST
C IBUFFR ARRAY LOCATION IN WHICH CHARACTER OF
C REPRESENTATION OF NUMBER IS RETURNED.
C PORTION OF IBUFFR ARRAY TO RIGHT OF
C REPRESENTATION AND EXTENDING THROUGH
C IBUFFR(MAXBFR) IS RETURNED UNDEFINED, BUT
C POSSIBLY CHANGED.
C
C FOLLOWING ARGUMENTS ARE USED ONLY FOR OUTPUT.
C
C IBUFFR = ARRAY IN WHICH CHARACTERS WHICH FORM
C REPRESENTATION OF NUMBER ARE RETURNED AS
C THOUGH READ BY MULTIPLE OF A1 FORMAT
C SPECIFICATION OR AS THOUGH DEFINED BY
C SEVERAL 1H FIELDS. LEFTMOST CHARACTER OF
C REPRESENTATION IS RETURNED IN
C IBUFFR(KOUNT+1).
C IERR = -1, RETURNED IF FIELD WAS TOO SHORT TO
C CONTAIN REPRESENTATION OF NUMBER. FIELD IS
C RETURNED CONTAINING ASTERISKS, AND KOUNT IS
C RETURNED SET EQUAL TO MAXBFR.
C = 0, RETURNED IF KONTRL IS LESS THAN OR EQUAL
C TO ZERO AND INTEGER VALUE COULD BE SHOWN, OR
C IF KONTRL IS GREATER THAN ZERO AND REAL
C VALUE WAS REPRESENTED IN FLOATING POINT
C FORM.
C = 1 OR GREATER, RETURNED IF KONTRL IS INPUT
C GREATER THAN ZERO AND VALUE WAS REPRESENTED
C IN SCIENTIFIC NOTATION. IERR IS NUMBER OF
C DIGITS WHICH WOULD BE SHOWN TO LEFT OF
C EXPONENT IF RIGHTMOST OF THESE DIGITS IS
C NONZERO. ZEROS WHICH ARE TO RIGHT OF
C DECIMAL POINT AND WHICH DO NOT HAVE NONZERO
C DIGIT TO THEIR RIGHT ARE NOT SHOWN BUT ARE
C INCLUDED IN VALUE OF IERR.
C
DIMENSION IBUFFR(MAXBFR)
DATA ISTAR/1H*/
LFTCOL=KOUNT
IF(KONTRL.GT.0)GO TO 2
C
C REPRESENT INTEGER
IRADIX=10
IF(KONTRL.LT.0)IRADIX=8
CALL DANUMB(0,IVALUE,IRADIX,IBUFFR,KOUNT,LFTCOL,
1MAXBFR)
IERR=0
IF(KOUNT.GT.LFTCOL)GO TO 3
IERR=-1
1 IF(KOUNT.GE.MAXBFR)GO TO 3
KOUNT=KOUNT+1
IBUFFR(KOUNT)=ISTAR
GO TO 1
C
C REPRESENT REAL NUMBER
2 LOWDEC=MINDEC
IF(LOWDEC.LE.0)LOWDEC=-1
NOTATN=0
IF(MAXSIG.LE.0)NOTATN=-1
IWIDTH=MAXBFR-LFTCOL
CALL DARITE(VALUE ,-1,NOTATN,0,0,
1-3,0,IWIDTH,LOWDEC,MAXDEC,MINSIG,MAXSIG,
2-1,0,IDECML,0,0,-1,LFTCOL,
3MAXBFR,IBUFFR,KOUNT,IERR)
C
C RETURN TO CALLING PROGRAM
3 RETURN
C227857143604
END