C Library Functions - almost (3)
NAME
almost(3f) - [M_framework__approx] return true or false if two numbers
agree up to specified number of digits
(LICENSE:PD)
CONTENTS
Synopsis
Description
Options
Returns
Examples
Author
License
SYNOPSIS
elemental impure function almost(x,y,digits,verbose)
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 |
| |
number of digits of precision to compare. May be INTEGER or
REAL.
|
|
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
|
|
EXAMPLES
sample:
program demo_almost
use M_framework__approx, only : almost
implicit none
real :: x, y
logical :: z
integer :: i
x=1.2345678
y=1.2300000
do i=1,8
z=almost(x,y,i,verbose=.true.)
write(*,*)i,z
enddo
end program demo_almost
Results:
> *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 ...
> digits out of requested 1.00000000
> 1 T
> *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 ...
> digits out of requested 2.00000000
> 2 T
> *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 ...
> digits out of requested 3.00000000
> 3 F
> *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 ...
> digits out of requested 4.00000000
> 4 F
> *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 ...
> digits out of requested 5.00000000
> 5 F
> *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 ...
> digits out of requested 6.00000000
> 6 F
> *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 ...
> digits out of requested 7.00000000
> 7 F
> *sp_accdig* significant digit request too high= 8.00000000
> *almost* for values 1.23456776 1.23000002 agreement of 2.43020344 ...
> digits out of requested 8.00000000
> 8 F
AUTHOR
John S. Urban
LICENSE
Public Domain
| Nemo Release 3.1 | almost (3) | June 29, 2025 |
Generated by manServer 1.08 from af23c5a3-3942-4e99-ad69-f09ec16adca8 using man macros.