C Library Functions - almost (3)
NAME
almost(3f) - [M_verify] 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
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
|
|
EXAMPLES
sample:
program demo_almost
use M_verify, 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,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
| Nemo Release 3.1 | almost (3) | June 29, 2025 |
Generated by manServer 1.08 from ffba8544-2be7-413b-9ad0-b8ef2405a160 using man macros.