File: example_math_is_close.f90

package info (click to toggle)
fortran-stdlib 0.8.1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 34,008 kB
  • sloc: f90: 24,178; ansic: 1,244; cpp: 623; python: 119; makefile: 13
file content (15 lines) | stat: -rw-r--r-- 450 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
program example_math_is_close

  use stdlib_math, only: is_close
  implicit none
  real :: x(2) = [1, 2], y, NAN

  y = -3
  NAN = sqrt(y)

  print *, is_close(x, [real :: 1, 2.1])       ! [T, F]
  print *, is_close(2.0, 2.1, abs_tol=0.1)    ! T
  print *, NAN, is_close(2.0, NAN), is_close(2.0, NAN, equal_nan=.true.)   ! NAN, F, F
  print *, is_close(NAN, NAN), is_close(NAN, NAN, equal_nan=.true.)        ! F, T

end program example_math_is_close