F90 的整數範圍

6 views
Skip to first unread message

sjgau02

unread,
Oct 27, 2007, 4:33:36 PM10/27/07
to NTUST_F90
! file: F1028.F90
implicit none
integer no
real x

!DEC$IF (.FALSE.)
no= 39
no= 117
no= 351
no= 1053
no= 3159
no= 9477
no= 28431
no= 85293
no= 255879
no= 767637
no= 2302911
no= 6908733
no= 20726199
no= 62178597
no= 186535791
no= 559607373
no= 1678822119
no= 741499061
no= -2070470113


*** exit the loop, no= -2070470113
x= 30.947311

上面的 x 顯示,F90 的整數,至少是 31個 bits
加上一個 bit 存正/負符號,一共是 32個 bits
也就是 4- Bytes
正確的範圍是

-2147483648 . . . +2147483647

Press any key to continue

!DEC$ENDIF
! -------------------------------------------

no= 13
do while (no .GT. 0)
no= no + no + no
write(*, '(1x, A, I12)') 'no= ', no
end do
write(*, '(1x, //1x, A, I12)')'*** exit the loop, no= ', no

no= -no
x= (log(real(no)))/(log(2.0))
write(*, '(1x, A, F10.6)')'x= ', x

end
! -------------------------------------------

Reply all
Reply to author
Forward
0 new messages