next up previous index
Next: M218 Convert Between Up: CERNLIB Previous: M214 Conversion To

M215 Find Power-of-Ten Scale for Printing

Routine ID: M215
Author(s): J. ZollLibrary: KERNLIB
Submitter: C. LetertreSubmitted: 01.09.1969
Language: FortranRevised: 15.09.1978

PSCALE gives the power of ten by which it is necessary to multiply a REAL number A for the purpose of obtaining a new REAL number B having a fixed number of digits on the left of the decimal point.

Structure:

FUNCTION subprogram
User Entry Names: PSCALE

Usage:

    FACT=PSCALE(N,NMAX,A,IDIG)
returns the largest N and its power FACT = 10.0**N, such that FACT*A has at most IDIG digits to the left of the decimal point. N is limited to ≤NMAX , however.

Examples:

Suppose we have an array B(100), which we want to print with a FORMAT(10F10.3). Using VMAXA (F121) we find the smallest number BMAX, such that BMAX ≥|B(I)| for all I. Then

    FACT=PSCALE(N,9,BMAX,4)
allows us to print the vector FACT*B(I) with the above FORMAT. The following sample values of BMAX give values for FACT as indicated below:
          BMAX                      FACT
    1234567800.                     10.0**(-6)
       1234567.8                    10.0**(-3)
          1234.5678                 1
             1.2345678              10.0**3
             0.0012345678           10.0**6
          1234.5678*10.0**(-9)      10.0**9
          1234.5678*10.0**(-12)     10.0**9
             0.0                    10.0**9
All FACT*BMAX but the two last ones, will be printed as 1234.567.

M218


Janne Saarela
Mon Apr 3 15:06:23 METDST 1995