James McIninch wrote:
The intrinsics of Fortran, such as COS, have been generic since at
least the Fortran 77 standard, meaning that COS(X) will call a single
or double precision version of the cosine function, and return a single
or double precision real, depending on the type of variable X.
variable _or value_ X. Explicitly declared variables can be equally
easily single or double -- or other system-dependent non-portable
precisions. Implicitly declared variables, such as under the hoary
"God is real" rule, are more easily single. Fortran floating-point
literals are single unless you use 'd' for the exponent, or in >= F90
the _kind syntax. Double real must occupy twice the space of single,
but need not actually be twice as precise.
C99, not yet widely implemented/available, includes single=float and
long double math functions as well as the classic double ones, and
adds complex variants where applicable, plus optional (if you #include
<tgmath.h>) generic 'wrappers' comparable to Fortran (and others).
(Since C89) long double although a distinct type need not actually be
more precise or bigger than double, especially in the M$ world; for
that matter double need not be better than float if that satisfies the
(minimum) requirements. Floating literals in C are double unless you
append 'f' float or 'l' long double.
Both languages permit calculations to be performed in greater than the
standardly-specified precision (and range) if the compiler prefers,
especially if as on a certain common machine it is costly to convert.
The OP also asked about integers. Fortran doesn't standardly require
more than one size/precision of integer, nor any unsigned. C has four
and C99 five nominally distinct precisions, in both signed and
unsigned (at least <G>), although again the 'higher' ones need not
actually be more precise (or bigger) as long as they meet minima.
- David.Thompson1 at worldnet.att.net