Re: large number with interger
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

 Up
Re: large number with interger         

Group: comp.lang.fortran · Group Profile
Author: Tobias Burnus
Date: Jan 29, 2008 06:16

On Jan 25, 7:11 pm, Kith gmail.com> wrote:
> I have a problem to deal with a large number with interger. The
> problem is I have to deal with integers of about 20 digits. I am using
> Fortran Professional version (2001). Currently, I am using
> integer(8) command but it takes only 12 digits. I would appreciate if
> someone could help me with this.

Some compilers might support INTEGER(16) (16 byte integers).

I actually thought that several compilers do so, but I just saw that
of my compiler seemingly only gfortran does so (on x86-64-linux; I
tried in total 6 compilers).

In any case with gfortran one can do "INTEGER(16) :: i", which allows
numbers up to
huge(1_16) = 170141183460469231731687303715884105727
which allows for selected_int_kind(38) and is thus enough for your 20
digit numbers.

This solution might be the easiest. Otherwise, one could use one of
the several multi precision libraries as proposed before.

GNU Fortran (gfortran) is available for almost all platforms, is Open
Source and thus free and can be downloaded, e.g., from
http://gcc.gnu.org/wiki/GFortranBinaries

Tobias
no comments
diggit! del.icio.us! reddit!

RELATED THREADS
SubjectArticles qty Group
Re: large file support && ! large file supportcomp.unix.programmer ·