Re: large number with interger



As another poster gave, Inteter*8 may or may not work for your case. If you need to go
above 20 digits, consider:
David Bailey's Multiple Precision package(F90) and extensive work:
http://www.nersc.gov/~dhbailey/

then visit and download files from:
http://crd.lbl.gov/~dhbailey/mpdist/

Here is a Mutilple Integer example:

!
!===Using David Bailey's MPFUN package this illustrates how to
! compute 500 Factorial exactly. Source code is at:
! http://crd.lbl.gov/~dhbailey/mpdist/
!
! Example of compile and link using g95:
! g95 -c mpfun90.f90
! g95 -c mpmod90.f90
! g95 testfac.f90 mpmod90.o mpfun90.o
!
use mpmodule !Defines MP Package's Modules.
use mpfunmod
implicit none
type (mp_integer) NUMOUT !Declare local MP Integer variable.
integer n

!---Set the number of digits output in MPWRITE to 1200 in this case;
! Factorial(500), which has 1135 digits, will output full accuracy.
! Note that precision defaults to 2000 digits.
!
call mpinit ! Used to initialize the MP package.
mpoud=1200 ! Resets output digits of MPWRITE statements.

n=500
call fact(n, NUMOUT)
write(*,*)'n=',n,' n!='
call mpwrite(6,NUMOUT)
end
subroutine fact(numin, NUMOUT)
! This subroutine evaluates the factorial of the argument
! using brute force definition of Factorial.
use mpmodule
implicit none
type (mp_integer) NUMOUT
integer numin, k

if ((numin == 0) .or. (numin == 1)) then
NUMOUT = 1
else
NUMOUT = 1
do k = 2, numin
NUMOUT = NUMOUT * k
end do
endif
return
! Output Display under Windows XP using the g95 binary as of 15 December 2005:
!
! C:\fort\mpbailey>a.exe
! N= 500 N!=
end

On Fri, 25 Jan 2008 10:11:11 -0800 (PST), Kith <kithsiri@xxxxxxxxx> wrote:

-|Hi all,
-|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.
-|Best regards,
-|Kith

.



Relevant Pages

  • Re: large number with interger
    ... You would unzip David Bailey's f90 package and then smply run one of the following ... del *.mod ... -| type NUMOUT!Declare local MP Integer variable. ... Factorial, which has 1135 digits, will output full accuracy. ...
    (comp.lang.fortran)
  • Re: Factorial function
    ... If you need to compute Factorial of largeg integers, you might try David Bailey's ... Multiple Prercision package: ... type NUMOUT!Declare local MP Integer variable. ... Factorial, which has 1135 digits, will output full accuracy. ...
    (comp.lang.fortran)
  • Re: ANSWER THE FCKING QUESTION GHOST
    ... "David C. Ullrich" wrote in message ... Remember how you said irrationals are perfect and rationals are real life approximations? ... It seems a few hundred digits was close enough for Planck and crew after all. ...
    (sci.math)
  • Re: ANSWER THE FCKING QUESTION GHOST
    ... "David C. Ullrich" wrote in message ... Remember how you said irrationals are perfect and rationals are real life approximations? ... It seems a few hundred digits was close enough for Planck and crew after all. ...
    (sci.logic)
  • Re: bijection of R: R <--> Rx.....xR
    ... >> on philosophical grounds: Although it turns out it doesn't ... >> terms of the decimal digits. ... >> David C. Ullrich ...
    (sci.math)