Currently I’m brushing up on my Fortran95 knowledge (don’t ask why)…
I’m running in to a problem though. How does one handle large integers, eg. the size of: ~700000000000
INTEGER(KIND=3) cannot hold this number.
If anyone is interested the compiler I have available is Silverfrost FTN95.
I am using the integer to run through a larger set of data.
Do you have any suggestions?
The standard solution (since Fortran 95, so I assume your compiler supports it) is to use the
SELECTED_INT_KINDintrinsic to probe for valid integer kinds (whose values are compiler dependent) and theHUGEintrinsic.SELECTED_INT_KIND (R)returns the kind type parameter of an integer type that represents all integer values n with −10^R < n < 10^R (and returns -1 if no such type exist).HUGE (K)returns the largest representable number in integer type of kind K.For example, on my Mac with an x86_64 processor (gfortran compiler, 64-bit mode), the following program:
outputs:
which tells me that I’d use an
integer(kind=8)for your job.