View previous topic :: View next topic |
Author |
Message |
jlb
Joined: 21 Oct 2020 Posts: 45
|
Posted: Thu Oct 22, 2020 11:34 am Post subject: Limitation for binary output of 64-bit integers? |
|
|
Only the first 32 least significant bits of KIND=4 integers are printed out while using B64 FORMAT descriptor.
Code: | 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
Last edited by jlb on Thu Oct 22, 2020 2:51 pm; edited 1 time in total |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Thu Oct 22, 2020 12:55 pm Post subject: |
|
|
There does appear to be an issue. An alternative compiler returns:
Quote: | -1
1111111111111111111111111111111111111111111111111111111111111111
9223372036854775807
0111111111111111111111111111111111111111111111111111111111111111 |
One for Paul or Robert methinks. |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1886
|
Posted: Thu Oct 22, 2020 2:01 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Fri Oct 23, 2020 8:51 am Post subject: |
|
|
jib
Thank you for the feedback. I have logged this failure. |
|
Back to top |
|
|
Kenneth_Smith
Joined: 18 May 2012 Posts: 697 Location: Hamilton, Lanarkshire, Scotland.
|
Posted: Fri Oct 23, 2020 9:49 am Post subject: |
|
|
Paul, I looked at this a bit more last night and this may help. Everything is ok up to and including i = 4294967295
Code: | 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 |
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Fri Oct 23, 2020 11:07 am Post subject: |
|
|
Thanks Ken.
I now have a fix that just needs testing. |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7928 Location: Salford, UK
|
Posted: Fri Oct 23, 2020 1:05 pm Post subject: |
|
|
This bug has now been fixed for the next release of the DLLs. |
|
Back to top |
|
|
jlb
Joined: 21 Oct 2020 Posts: 45
|
Posted: Fri Oct 23, 2020 3:44 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
|