Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to calculate >15 bit computing?

Status
Not open for further replies.

fishwater00

Technical User
Dec 1, 2011
4
US
In fortran, the highest precision is 15bit, I wanna calculate around 20-bit calculation, how can I do that? Thank you
 
The highest precision in Fortran is not 15.

- it exists real types having a higher precision than DOUBLE PRECISION
- it exists libraries or modules providing derived types with arbitrary precision (ARPREC for instance for C++ and F90 softwares)

The easiest example :

Code:
program test

  integer,parameter :: ep=selected_real_kind(20) ! at least 20 significant digits

  REAL(ep) :: pi
  pi=4*ATAN(1._ep)

  write(*,*) pi

end program

Result with the Intel fortran compiler (ifort (IFORT) 11.1 20100414) :

Code:
[lcoul@localhost test]$ ifort t58.f90
[lcoul@localhost test]$ ./a.out
   3.14159265358979323846264338327950



François Jacq
 
Thanks for your response, new issue comes out:

The maximum real precision is selected_real_kind(31) (I got from other book).

For integer, the maximum precision is selected_int_kind(16), is it right?

 
For integer, the maximum precision is selected_int_kind(16), is it right?

It may depend on the compiler but the usual limitation for integers is selected_int_kind(18) (the order of magnitude of 2**63)

François Jacq
 
Note that selected_int_kind specifies the number of significant digits: not the number of bits. If you use a 32 bit compiler on a 32 bit machine, you will get more than 20 bits accuracy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top