Real constants and functions: Difference between revisions
Content added Content deleted
(→Pascal: standardize, →Delphi: shorten and make reference to →Pascal: , insert →Free Pascal: [reference to →Delphi: ]) |
|||
Line 857: | Line 857: | ||
=={{header|Delphi}}== |
=={{header|Delphi}}== |
||
Delphi supports all basic Standard Pascal (ISO 7185) functions shown in [[#Pascal|§ Pascal]]. |
|||
Log, Floor, Ceil and Power functions defined in Math.pas. |
|||
Furthermore, the following is possible, too: |
|||
<lang Delphi> |
<lang Delphi>Pi; // π (Pi) |
||
Pi; // π (Pi) |
|||
Sqrt(x); // square root |
|||
LogN(BASE, x) // log of x for a specified base |
LogN(BASE, x) // log of x for a specified base |
||
Log2(x) // log of x for base 2 |
Log2(x) // log of x for base 2 |
||
Log10(x) // log of x for base 10 |
Log10(x) // log of x for base 10 |
||
Ln(x); // natural logarithm (for good measure) |
|||
Exp(x); // exponential |
|||
Abs(x); // absolute value (a.k.a. "magnitude") |
|||
Floor(x); // floor |
Floor(x); // floor |
||
Ceil(x); // ceiling |
Ceil(x); // ceiling |
||
Power(x, y); // power</lang> |
Power(x, y); // power</lang> |
||
Note, <tt>Log</tt>, <tt>Floor</tt>, <tt>Ceil</tt> and <tt>Power</tt> are from the <tt>Math</tt> unit, which needs to be listed in the <tt>uses</tt>-clauses. |
|||
=={{header|DWScript}}== |
=={{header|DWScript}}== |
||
⚫ | |||
⚫ | |||
=={{header|E}}== |
=={{header|E}}== |
||
Line 1,163: | Line 1,158: | ||
24.70529422006547 |
24.70529422006547 |
||
</pre> |
</pre> |
||
=={{header|Free Pascal}}== |
|||
''See [[#Delphi|Delphi]]'' |
|||
=={{header|Frink}}== |
=={{header|Frink}}== |
||
Line 2,246: | Line 2,244: | ||
=={{header|Pascal}}== |
=={{header|Pascal}}== |
||
''See also [[#Delphi|Delphi]] and [[#Free Pascal|Free Pascal]]''<br/> |
|||
See [[Real_constants_and_functions#Delphi | Delphi]] |
|||
Following functions are defined by ISO standard 7185, Standard “Unextended” Pascal, and supported by any processor: |
|||
<lang pascal> { Euler’s constant } |
|||
exp(1) |
|||
{ principal square root of `x` } |
|||
sqrt(x) |
|||
{ natural logarithm } |
|||
ln(x) |
|||
{ exponential } |
|||
exp(x) |
|||
{ absolute value } |
|||
abs(x)</lang> |
|||
{{works with|Extended Pascal}} |
|||
Additionally, in Extended Pascal (ISO standard 10206) following operators and expressions can be used: |
|||
<lang pascal> { Pi } |
|||
2 * arg(cmplx(0.0, maxReal)) |
|||
{ power, yields same data type as `base`, `exponent` has to be an `integer` } |
|||
base pow exponent |
|||
{ `real` power, `exponent` may be an `integer` or `real` value, yet `base` and } |
|||
{ `exponent` are automatically promoted to an approximate `real` value, result } |
|||
{ is `complex` if `base` is `complex`, otherwise a `real` value } |
|||
base ** exponent</lang> |
|||
<tt>Exp</tt>, <tt>sqrt</tt>, <tt>ln</tt>, and <tt>exp</tt> return <tt>real</tt> values, but a <tt>complex</tt> value if supplied with a <tt>complex</tt> value. |
|||
<tt>Abs</tt> always returns a value of the same data type as its argument. |
|||
=={{header|Perl}}== |
=={{header|Perl}}== |