Silverfrost Forums

Welcome to our forums

Limitation for binary output of 64-bit integers?

22 Oct 2020 10:34 (Edited: 22 Oct 2020 1:51) #26511

Only the first 32 least significant bits of KIND=4 integers are printed out while using B64 FORMAT descriptor.

PROGRAM bin
INTEGER(KIND=4),PARAMETER :: i=-1
  WRITE(*,*) i
  WRITE(*,'(1X,B64.64)') i
  WRITE(*,*) HUGE(i)
  WRITE(*,'(1X,B64.64)') HUGE(i)
END PROGRAM bin

produces this output: -1 0000000000000000000000000000000011111111111111111111111111111111 9223372036854775807 0000000000000000000000000000000011111111111111111111111111111111

Is there a limitation by norm?

** Nota:**

Same results using Win32 and x64 versions Compiler Version 8.61 Compiler options: /LINK resp. /64 /LINK

22 Oct 2020 11:55 #26512

There does appear to be an issue. An alternative compiler returns:

               -1

1111111111111111111111111111111111111111111111111111111111111111 9223372036854775807 0111111111111111111111111111111111111111111111111111111111111111

One for Paul or Robert methinks.

22 Oct 2020 1:01 #26513

With bug reports of this nature, it will be helpful if the OP reports, in addition:

 (i) whether a 32-bit or 64-bit executable, or both, exhibit(s) the described behaviour,

 (ii) the compiler version used,

 (iii) the compiler options used.
23 Oct 2020 7:51 #26516

jib

Thank you for the feedback. I have logged this failure.

23 Oct 2020 8:49 #26517

Paul, I looked at this a bit more last night and this may help. Everything is ok up to and including i = 4294967295

winapp
program bin
implicit none
integer(kind=4)i
integer k
  i = 4294967290_4
  
  do k = 1, 10
    print*
    write(*,'(I12,5X,B0)') i,i
    i = i + 1
  end do
  
end program bin
23 Oct 2020 10:07 #26518

Thanks Ken.

I now have a fix that just needs testing.

23 Oct 2020 12:05 #26519

This bug has now been fixed for the next release of the DLLs.

23 Oct 2020 2:44 #26520

Paul Thanks a lot for the rapid treating of this issue.

Kenneth I am sorry for having been imprecise with 'only the first 32 least significant bits are printed out'. I implied herewith that the bit representation of positive integers up to 2^32 -1 is correct. Thanks for the trial on an alternative compiler.

Please login to reply.