Steven G. Kargl
2023-11-04 21:21:53 UTC
The SCALE intrinsic allows one to change the
floating point exponent for a REAL entity.
For example,
program foo
real x
x = 1
print *, scale(x,1) ! print 2
end program
This scaling does not incur a floating point
rounding error.
Question. Anyone know why the Fortran standard (aka J3)
restricted X to be a REAL entity? It would seem that X
could be COMPLEX with obvious equivalence of
SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))
Should the Fortran be amended?
floating point exponent for a REAL entity.
For example,
program foo
real x
x = 1
print *, scale(x,1) ! print 2
end program
This scaling does not incur a floating point
rounding error.
Question. Anyone know why the Fortran standard (aka J3)
restricted X to be a REAL entity? It would seem that X
could be COMPLEX with obvious equivalence of
SCALE(X,N) = COMPLX(SCALE(X%RE,N),SCALE(X%IM,N),KIND(X%IM))
Should the Fortran be amended?
--
steve
steve