Real constants and functions: Difference between revisions

Content added Content deleted
Line 179: Line 179:
=={{header|Groovy}}==
=={{header|Groovy}}==
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'''
=====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:
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 185: Line 186:
<pre>22</pre>
<pre>22</pre>


'''Power'''
=====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:
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>