[UP]


Manual Reference Pages  - dp_accdig (3)

NAME

dp_accdig(3f) - [M_verify] compare two numbers only up to a specified number of digits (LICENSE:PD)

CONTENTS

Synopsis
Description
Example
Notes
References
Dependencies
Authors
License

SYNOPSIS

subroutine dp_accdig(x,y,digio,acurcy,ind)

       class(*),intent(in)  :: X
       class(*),intent(in)  :: Y
       class(*),intent(in)  :: DIGI0
       real,intent(out)     :: acurcy
       integer,intent(out)  :: ind

DESCRIPTION

This procedure is used to check how closely two numbers agree.

      call dp_accdig(X,Y,DIGI0,ACURCY,IND)

The values X and Y are the numbers to compare, and DIGI0 is the threshold number of digits to consider significant in returning IND.

If X and Y are considered equal within DIGI0 relative tolerance,

       IND    = 0, if tolerance is     satisfied.
              = 1, if tolerance is not satisfied.

The result ACURCY gives a measure of the number of leading digits in X which are the same as the number of leading digits in Y.

        ACURCY=-log10((X-Y)/Y)   if X != Y and Y != 0
        ACURCY=-log10(X-Y)       if X != Y and Y = 0
        ACURCY=8                 if X=Y

ACURCY is never less than -8 or greater than 8 for REAL values

TOLERANCE ... X and Y are considered equal within DIGI0 relative tolerance, if ACURCY is greater than DIGI0.
For example, Take some numbers and compare then
  to 1.2345678 ...
      ================================================
      A number     |    ACURCY       |   ACURCY
                   |    1.2345678=Y  |   1.2345678=X
      ================================================
       1.234680    |    3.7900571    |   3.7901275
       1.2345378   |    4.6144510    |   4.6144404
       2.2234568   |    0.096367393  |   0.35188114
       1.2345678   |    8.0000000    |   8.0000000
       1.2345679   |    7.0732967    |   7.0731968
      -1.2345678   |   -0.30103000   |  -0.30103000
      76.234567    |   -1.7835463    |   0.0070906729
       2.4691356   |    0.0          |   0.3010300
       0.0         |    0.0          |  -0.91514942.

Due to the typical limits of the log function, the number of significant digits in the result is best considered to be three.

Notice that 1.2345678=Y produces different values than 1.2345678=X

A negative result indicates the two values being compared either do not agree in the first digit or they differ with respect to sign. An example of two numbers which do not agree in their leading digit (and actually differ in order of magnitude) is given above by X=76.234567 and Y=1.2345678; the accuracy reported is -1.7835463. An example of two numbers which do not agree in sign in X=-1.2345678 and Y=1.2345678; here the accuracy reported is -0.30103000.

EXAMPLE

Example program:

   program demo_dp_accdig ! fortran 90 example
   use M_verify, only : dp_accdig
   implicit none
   integer         :: digi
   doubleprecision :: a, b
   integer         :: i10, i20, i30
   integer         :: ind, ind1, ind2
   real            :: acurcy, acurcy1, acurcy2
   doubleprecision :: vals(9)
   data vals/ &
     &1.234680d0,   1.2345378d0,  2.2234568d0, 1.2345678d0, &
     &1.2345679d0, -1.2345678d0, 76.234567d0,  2.4691356d0, &
     &0.0d0/
      write(*,*)’=========================’
      do i10=0,16
         a=1.0d0
         b=a+1.0d0/(10**i10)
         call dp_accdig(a,b,8.0,acurcy,ind)
         write(*,*)i10,a,b,acurcy,ind
      enddo
      write(*,*)’=========================’
      digi=16
      do i20=0,digi
         a=1.0d0
         b=a+1.0d0/(10**i20)
         call dp_accdig(a,b,dble(digi),acurcy,ind)
         write(*,*)i20,a,b,acurcy,ind
      enddo
      write(*,*)’=========================’
      do i30=1,9
         call dp_accdig(1.2345678d0,vals(i30),8.0,acurcy1,ind1)
         call dp_accdig(vals(i30),1.2345678d0,8.0,acurcy2,ind2)
         write(*,*)i30,vals(i30),acurcy1,acurcy2,ind1,ind2
      enddo
   end program demo_dp_accdig

NOTES

REFERENCES

based on ...

   NBS OMNITAB 1980 VERSION 6.01  1/ 1/81. dp_accdig V 7.00  2/14/90. **
      David Hogben,
      Statistical Engineering Division,
      Center for Computing and Applied Mathematics,
      A337 Administration Building,
      National Institute of Standards and Technology,
      Gaithersburg, MD 20899
                     TELEPHONE 301-975-2845
          ORIGINAL VERSION -  October, 1969.
           CURRENT VERSION - February, 1990.
           JSU     VERSION - February, 1991.

DEPENDENCIES

o M_journal(), log10(), abs(1)

AUTHORS

David Hogben, John S. Urban

LICENSE

Public Domain


dp_accdig (3) March 11, 2021
Generated by manServer 1.08 from 018c9a7e-575f-4050-bfc1-1bcc9ed9e726 using man macros.