Jump to content

Real constants and functions: Difference between revisions

Line 179:
=={{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>
Line 185 ⟶ 186:
<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>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.