Real constants and functions: Difference between revisions
Content added Content deleted
(→{{header|Fortran}}: Details, details...) |
|||
Line 647: | Line 647: | ||
=={{header|Fortran}}== |
=={{header|Fortran}}== |
||
<lang fortran> |
<lang fortran> |
||
e ! Not available. Can be calculated EXP(1.0) |
|||
pi ! Not available. Can be calculated 4.0*ATAN(1.0) |
pi ! Not available. Can be calculated 4.0*ATAN(1.0) |
||
SQRT(x) ! square root |
SQRT(x) ! square root |
||
Line 657: | Line 658: | ||
CEILING(x) ! ceiling - Fortran 90 or later only |
CEILING(x) ! ceiling - Fortran 90 or later only |
||
x**y ! x raised to the y power</lang> |
x**y ! x raised to the y power</lang> |
||
4*ATAN(1.0) will be calculated in single precision, likewise EXP(1.0) (not EXP(1), because 1 is an integer) and although double precision functions can be named explicitly, 4*DATAN(1.0) will be rejected because 1.0 is in single precision and DATAN expects double. Thus, 4*DATAN(1.0D0) or 4*DATAN(1D0) will do, as the D in the exponent form specifies double precision. Whereupon, the generic names can be returned to: 4*ATAN(1D0). Some systems go further and offer quadruple precision. Others allow that all constants will be deemed double precision as a compiler option. |
|||
The 4 need not be named as 4.0, or 4D0, as 4 the integer will be converted by the compiler to double precision, because it is to meet a known double precision value in simple multiplication and so will be promoted. Hopefully, at compile time. |
|||
=={{header|Frink}}== |
=={{header|Frink}}== |