nearest_2.f90

来自「用于进行gcc测试」· F90 代码 · 共 168 行

F90
168
字号
! { dg-do run }! { dg-options "-fno-range-check" }! { dg-options "-fno-range-check -mieee" { target sh*-*-* } }!! PR fortran/34192!! Test compile-time implementation of NEAREST!program test  implicit none! Single precision  ! 0+ > 0  if (nearest(0.0, 1.0) &      <= 0.0) &    call abort()  ! 0++ > 0+  if (nearest(nearest(0.0, 1.0), 1.0) &      <= nearest(0.0, 1.0)) &    call abort()  ! 0+++ > 0++  if (nearest(nearest(nearest(0.0, 1.0), 1.0), 1.0) &      <= nearest(nearest(0.0, 1.0), 1.0)) &    call abort()  ! 0+- = 0  if (nearest(nearest(0.0, 1.0), -1.0) &      /= 0.0) &    call abort()  ! 0++- = 0+  if (nearest(nearest(nearest(0.0, 1.0), 1.0), -1.0) &      /= nearest(0.0, 1.0)) &    call abort()  ! 0++-- = 0  if (nearest(nearest(nearest(nearest(0.0, 1.0), 1.0), -1.0), -1.0) &      /= 0.0) &    call abort()  ! 0- < 0  if (nearest(0.0, -1.0) &      >= 0.0) &    call abort()  ! 0-- < 0+  if (nearest(nearest(0.0, -1.0), -1.0) &      >= nearest(0.0, -1.0)) &    call abort()  ! 0--- < 0--  if (nearest(nearest(nearest(0.0, -1.0), -1.0), -1.0) &      >= nearest(nearest(0.0, -1.0), -1.0)) &    call abort()  ! 0-+ = 0  if (nearest(nearest(0.0, -1.0), 1.0) &      /= 0.0) &    call abort()  ! 0--+ = 0-  if (nearest(nearest(nearest(0.0, -1.0), -1.0), 1.0) &      /= nearest(0.0, -1.0)) &    call abort()  ! 0--++ = 0  if (nearest(nearest(nearest(nearest(0.0, -1.0), -1.0), 1.0), 1.0) &      /= 0.0) &    call abort()  ! 42++ > 42+  if (nearest(nearest(42.0, 1.0), 1.0) &      <= nearest(42.0, 1.0)) &    call abort()  ! 42-- < 42-  if (nearest(nearest(42.0, -1.0), -1.0) &      >= nearest(42.0, -1.0)) &    call abort()  ! 42-+ = 42  if (nearest(nearest(42.0, -1.0), 1.0) &      /= 42.0) &    call abort()  ! 42+- = 42  if (nearest(nearest(42.0, 1.0), -1.0) &      /= 42.0) &    call abort()  ! INF+ = INF  if (nearest(1.0/0.0, 1.0) /= 1.0/0.0) call abort()  ! -INF- = -INF  if (nearest(-1.0/0.0, -1.0) /= -1.0/0.0) call abort()  ! NAN- = NAN  if (.not.isnan(nearest(0.0d0/0.0,  1.0))) call abort()  ! NAN+ = NAN  if (.not.isnan(nearest(0.0d0/0.0, -1.0))) call abort()! Double precision  ! 0+ > 0  if (nearest(0.0d0, 1.0) &      <= 0.0d0) &    call abort()  ! 0++ > 0+  if (nearest(nearest(0.0d0, 1.0), 1.0) &      <= nearest(0.0d0, 1.0)) &    call abort()  ! 0+++ > 0++  if (nearest(nearest(nearest(0.0d0, 1.0), 1.0), 1.0) &      <= nearest(nearest(0.0d0, 1.0), 1.0)) &    call abort()  ! 0+- = 0  if (nearest(nearest(0.0d0, 1.0), -1.0) &      /= 0.0d0) &    call abort()  ! 0++- = 0+  if (nearest(nearest(nearest(0.0d0, 1.0), 1.0), -1.0) &      /= nearest(0.0d0, 1.0)) &    call abort()  ! 0++-- = 0  if (nearest(nearest(nearest(nearest(0.0d0, 1.0), 1.0), -1.0), -1.0) &      /= 0.0d0) &    call abort()  ! 0- < 0  if (nearest(0.0d0, -1.0) &      >= 0.0d0) &    call abort()  ! 0-- < 0+  if (nearest(nearest(0.0d0, -1.0), -1.0) &      >= nearest(0.0d0, -1.0)) &    call abort()  ! 0--- < 0--  if (nearest(nearest(nearest(0.0d0, -1.0), -1.0), -1.0) &      >= nearest(nearest(0.0d0, -1.0), -1.0)) &    call abort()  ! 0-+ = 0  if (nearest(nearest(0.0d0, -1.0), 1.0) &      /= 0.0d0) &    call abort()  ! 0--+ = 0-  if (nearest(nearest(nearest(0.0d0, -1.0), -1.0), 1.0) &      /= nearest(0.0d0, -1.0)) &    call abort()  ! 0--++ = 0  if (nearest(nearest(nearest(nearest(0.0d0, -1.0), -1.0), 1.0), 1.0) &      /= 0.0d0) &    call abort()  ! 42++ > 42+  if (nearest(nearest(42.0d0, 1.0), 1.0) &      <= nearest(42.0d0, 1.0)) &    call abort()  ! 42-- < 42-  if (nearest(nearest(42.0d0, -1.0), -1.0) &      >= nearest(42.0d0, -1.0)) &    call abort()  ! 42-+ = 42  if (nearest(nearest(42.0d0, -1.0), 1.0) &      /= 42.0d0) &    call abort()  ! 42+- = 42  if (nearest(nearest(42.0d0, 1.0), -1.0) &      /= 42.0d0) &    call abort()  ! INF+ = INF  if (nearest(1.0d0/0.0d0, 1.0) /= 1.0d0/0.0d0) call abort()  ! -INF- = -INF  if (nearest(-1.0d0/0.0d0, -1.0) /= -1.0d0/0.0d0) call abort()  ! NAN- = NAN  if (.not.isnan(nearest(0.0d0/0.0,  1.0))) call abort()  ! NAN+ = NAN  if (.not.isnan(nearest(0.0d0/0.0, -1.0))) call abort()end program test

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?