https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107716

--- Comment #1 from urbanjost at comcast dot net ---
I am on a Linux mint box using KVM and
running a virtual box that is
   OpenBSD mo.my.domain 7.2 GENERIC#381 i386
using
   GNU Fortran (GCC) 11.2.0
and am getting negative values from NINT()
on doubleprecision values when I do not expect
them.

I thought NINT() took any KIND of REAL so I did
not expect that; but it has been a while since
I ran on i386, and I am on a virtual box.

If I do a NINT(REAL(value)) instead of NINT(value)
I get the expected INTEGER value.

Any reason I should expect NINT() to not work
with values still within the range of the default
INTEGER kind?

Anyone have a 32-bit box with gfortran on it that
could see if they start getting negative values
with doubleprecision input values below HUGE(0)?

     >   program testit
     >   use,intrinsic :: iso_fortran_env, only : int8, int16, int32, int64
     >   use,intrinsic :: iso_fortran_env, only : real32, real64, real128
     >   implicit none
     >   doubleprecision :: value
     >   integer :: i
     >   do i=0,huge(0)-1
     >   value=i
     >   if(nint(value).lt.0)then
     >      write(*,*)'VALUE:',value
     >      write(*,*)'REAL(VALUE):',real(value)
     >      write(*,*)'NINT(REAL(VALUE)):',nint(real(value))
     >      write(*,*)'NINT(VALUE):',nint(value-1)
     >      write(*,*)'NINT(VALUE):',nint(value)
     >      write(*,*)'NINT(VALUE):',nint(value+1)
     >      write(*,*)'INT:',int(value-1)
     >      write(*,*)'INT:',int(value)
     >      write(*,*)'INT:',int(value+1)
     >      exit
     >   endif
     >   enddo
     >   write(*,*)'value:',value
     >   write(*,*)'huge(0):',huge(0)
     >   write(*,*)'huge(0_int64):',huge(0_int64)
     >   write(*,*)'huge(0_int32):',huge(0_int32)
     >   write(*,*)'huge(0_int16):',huge(0_int16)
     >   write(*,*)'huge(0_int8):',huge(0_int8)
     >   end program testit
     >   
     >    VALUE:   2097153.0000000000     
     >    REAL(VALUE):   2097153.00    
     >    NINT(REAL(VALUE)):     2097153
     >    NINT(VALUE):     2097152
     >    NINT(VALUE):          -1
     >    NINT(VALUE):     2097154
     >    INT:     2097152
     >    INT:     2097153
     >    INT:     2097154
     >    value:   2097153.0000000000     
     >    huge(0):  2147483647
     >    huge(0_int64):  9223372036854775807
     >    huge(0_int32):  2147483647
     >    huge(0_int16):  32767
     >    huge(0_int8):  127


It starts off with just odd numbers getting a -1 return

Reply via email to