PRECISION intrinsic function
Standard: F77 F90 F95 F2003 F2008
 Example Program

X : scalar or array of type Real or Complex;

Result : scalar Integer, default kind.

This function returns the decimal precision of floating-point numbers that have the same kind as X. The result is equal to INT((DIGITS(X)-1)*LOG10(REAL(RADIX(X))))+k, where k is 1 if RADIX(X) is an integral power of 10, and 0 otherwise; thus all decimal integers with PRECISION(X) digits (or fewer) can be exactly represented in this kind, but not all integers with PRECISION(X)+1 digits can be.

Note that if X is Complex, PRECISION(X) is equal to PRECISION(REAL(X)) and also PRECISION(AIMAG(X)), i.e. it is the precision of the real and imaginary parts.

This is an inquiry function, so X need not be defined; indeed, it is permitted to be an unallocated allocatable or a disassociated or undefined pointer.

DIGITS intrinsic function, RADIX intrinsic function, REAL type, SELECTED_REAL_KIND intrinsic function.