next up previous contents
Next: Numerical Intrinsic Functions Up: Intrinsic Functions Previous: Generic vs. Specific Functions   Contents

Numerical Type Conversions

In what follows we will use the short notation I,R,D,C for INTEGER, REAL, DOUBLE PRECISION and COMPLEX.

For example,


For example,
{}
integer :: i=2
real ::    t=1.7
double precision :: x=1.7d0,y=2.8d0
complex :: z=(1.7,2.8)
print*, x, real(x) ! output = 1.7,  1.70000005
print*, real(z), aimag(z) ! output = 1.70000005,  2.79999995
print*, dble(t) ! output = 1.7000000476837158
print*, cmplx(i), cmplx(z) ! output = (2.,0.e+0),  (1.70000005,2.79999995)
Note the errors in double to real and real to double conversions, as well as the representation errors.


next up previous contents
Next: Numerical Intrinsic Functions Up: Intrinsic Functions Previous: Generic vs. Specific Functions   Contents
Adrian Sandu 2001-08-26