Real constants and functions: Difference between revisions
Content added Content deleted
m (→{{header|Tcl}}: formatting) |
|||
Line 176: | Line 176: | ||
CEILING(x) ! ceiling - Fortran 90 or later only |
CEILING(x) ! ceiling - Fortran 90 or later only |
||
x**y ! x raised to the y power |
x**y ! x raised to the y power |
||
=={{header|Groovy}}== |
|||
Math constants and functions are as outlined in the [[#Java Java]] example, except as follows: |
|||
'''Absolute Value''' |
|||
In addition to the java.lang.Math.abs() method, each numeric type has an abs() method, which can be invoked directly on the number: |
|||
<lang groovy>println ((-22).abs())</lang> |
|||
Output: |
|||
<pre>22</pre> |
|||
'''Power''' |
|||
In addition to the java.lang.Math.pow() method, each numeric type works with the power operator (**), which can be invoked as an in-fix operator between two numbers: |
|||
<lang groovy>println 22**3.5</lang> |
|||
Output: |
|||
<pre>49943.547010599876</pre> |
|||
Power results are not defined for all possible pairs of operands. Any power operation that does not have a result returns a 64-bit IEEE NaN (Not a Number) value. |
|||
<lang groovy>println ((-22)**3.5)</lang> |
|||
Output: |
|||
<pre>NaN</pre> |
|||
Also note that at the moment (2009-05-24) Groovy (1.6.2) gives a mathematically incorrect result for "0**0". The correct result should be "NaN", but the Groovy operation result is "1". |
|||
=={{header|Haskell}}== |
=={{header|Haskell}}== |