Real constants and functions: Difference between revisions
Content added Content deleted
Line 180: | Line 180: | ||
Math constants and functions are as outlined in the [[#Java Java]] example, except as follows: |
Math constants and functions are as outlined in the [[#Java Java]] example, except as follows: |
||
'''Absolute Value'''<br/> |
|||
In addition to the java.lang.Math.abs() method, each numeric type has an abs() method, which can be invoked directly on the number: |
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> |
<lang groovy>println ((-22).abs())</lang> |
||
Line 186: | Line 186: | ||
<pre>22</pre> |
<pre>22</pre> |
||
'''Power'''<br/> |
|||
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: |
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> |
<lang groovy>println 22**3.5</lang> |
||
Line 197: | Line 197: | ||
<pre>NaN</pre> |
<pre>NaN</pre> |
||
Also note that at the moment ( |
Also note that at the moment (--21:58, 24 May 2009 (UTC)) 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}}== |