[UP]


Manual Reference Pages  - almost (3)

NAME

almost(3f) - [M_math] return true or false if two numbers agree up to specified number of digits (LICENSE:PD)

CONTENTS

Synopsis
Description
Options
Returns
Example
Author
License

SYNOPSIS

function almost(x,y,digits)

    class(*),intent(in)         :: x,y
    class(*),intent(in)         :: rdigits
    logical,intent(in),optional :: verbose
    logical                     :: almost

DESCRIPTION

Returns true or false depending on whether the two numbers given agree to within the specified number of digits as calculated by ACCDIG(3f).

OPTIONS

x,y expected and calculated values to be compared. May be of type REAL, INTEGER, or DOUBLEPRECISION.
rdigits
  real number representing number of digits of precision to compare
verbose
  optional value that specifies to print the results of the comparison when set to .TRUE..

RETURNS

almost TRUE if the input values compare up to the specified number of values

EXAMPLE

sample:

   program demo_almost
   use M_math, only : almost
   real    :: x, y
   logical :: z
   x=1.2345678
   y=1.2300000
   do i=1,8
      z=almost(x,y,real(i),verbose=.true.)
      write(*,*)i,z
   enddo
   end program demo_almost

output:

    *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 digits out of requested 1.0
           1   T
    *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 digits out of requested 2.0
           2   T
    *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 digits out of requested 3.0
           3   F
    *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 digits out of requested 4.0
           4   F
    *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 digits out of requested 5.0
           5   F
    *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 digits out of requested 6.0
           6   F
    *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 digits out of requested 7.0
           7   F
    *accdig* significant digit request too high= 8.00000000
    *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 digits out of requested 8.0
           8   F

AUTHOR

John S. Urban

LICENSE

Public Domain


almost (3) October 17, 2020
Generated by manServer 1.08 from 7c7dcec9-beb2-4e07-8b5c-8da628b10527 using man macros.