[R] Fortran and long integers
David Duffy
davidD at qimr.edu.au
Mon Feb 7 13:24:48 CET 2011
On Mon, 7 Feb 2011, Berend Hasselman <bhh at xs4all.nl> wrote:
> The overflow is not caused by 16 bits integers.
> I'm quite sure the OP is using 32 bit integers.
> The overflow is caused by the multiplication N*(i-1) and/or i*(i+1).
> In Fortran there's not much you can do about this unless your compiler
> supports larger integers.
Most modern Fortran compilers offer larger integers. The
selected_int_kind() function can be used to find the appropriate integer
KIND for your compiler. Most, like gfortran, use kind=8 for long integer
integer (kind=8) :: i16
write(*,*) huge(i16)
9223372036854775807
--
| David Duffy (MBBS PhD) ,-_|\
| email: davidD at qimr.edu.au ph: INT+61+7+3362-0217 fax: -0101 / *
| Epidemiology Unit, Queensland Institute of Medical Research \_,-._/
| 300 Herston Rd, Brisbane, Queensland 4029, Australia GPG 4D0B994A v
More information about the R-help
mailing list