Re: large number with interger
- From: Herman D. Knoble <SkipKnobleLESS@xxxxxxxxxxxxxxx>
- Date: Tue, 29 Jan 2008 07:23:48 -0500
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
.
- Follow-Ups:
- Re: large number with interger
- From: Herman D . Knoble
- Re: large number with interger
- References:
- large number with interger
- From: Kith
- large number with interger
- Prev by Date: Re: Problem reading data from a file (encounter EOF after second last record)
- Next by Date: Re: installing fruit
- Previous by thread: Re: large number with interger
- Next by thread: Re: large number with interger
- Index(es):
Relevant Pages
|
|