/usr/share/doc/libantelope-java/manual/bk03ch15.html is in libantelope-java-doc 3.5.1-3.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 | <html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"><title>Chapter 15. Math</title><meta name="generator" content="DocBook XSL Stylesheets V1.78.1"><link rel="home" href="index.html" title="Antelope Users Guide"><link rel="up" href="bk03.html" title="Additional Ant Tasks"><link rel="prev" href="bk03ch14.html" title="Chapter 14. UID"><link rel="next" href="bk03ch16.html" title="Chapter 16. Hostname"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">Chapter 15. Math</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="bk03ch14.html">Prev</a> </td><th width="60%" align="center">Additional Ant Tasks</th><td width="20%" align="right"> <a accesskey="n" href="bk03ch16.html">Next</a></td></tr></table><hr></div><div class="chapter"><div class="titlepage"><div><div><h1 class="title"><a name="math"></a>Chapter 15. Math</h1></div></div></div>
@style@
<p>
The Math task provides support for all the basic mathematical operations
provided by the java.lang.Math and java.lang.StrictMath classed. It supports int, long, float and double data types. Nesting of operations is supported to allow computation of formulas like (6 + (7.25 * 3.9))/(2 * 3 * 3) or calculating the area of a circle given a radius (I'm sure this comes up often in builds controlled by Ant!).
</p><p>
In addition to the operations provided by the java.lang.Math and java.lang.StrictMath classes, the Math task provides several additional operations: "add", "subtract", "multiply", "divide", and "mod", which duplicate the basic Java mathematical operations "+", "-", "*", "/", and "%", respectively. In fact, either notation can be used, that is, the operation can be set to "add" or "+", depending only on which you feel is more convenient.
</p><p>
To use this task in your build files, include a task definition like this:
</p><p>
</p><pre class="programlisting">
<taskdef name="math" classname="ise.antelope.tasks.MathTask"/>
</pre><p>
</p><p>
</p><div class="table"><a name="idp62535232"></a><p class="title"><b>Table 15.1. Math Task Attributes</b></p><div class="table-contents"><table summary="Math Task Attributes" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td>result</td><td>The name of the property to hold the result of the operation.</td><td>None</td><td>Yes</td></tr><tr><td>datatype</td><td>Sets the datatype of the calculation. Allowed values are
"int", "long", "float", or "double". Optional, if
used, will be applied to all numbers in this math operation.</td><td>double</td><td>No</td></tr><tr><td>strict</td><td>If true, use the methods in the java.lang.StrictMath class.</td><td>false</td><td>No</td></tr><tr><td>operation</td><td>If used, any nested Ops will be ignored. This is for convenience for simple calculations.</td><td>None</td><td>No</td></tr><tr><td>operand1</td><td>A number to use with the operation specified in the 'operation' attribute.</td><td>None</td><td>Depends on the specific operation.</td></tr><tr><td>operand2</td><td>A number to use with the operation specified in the 'operation' attribute.</td><td>None</td><td>Depends on the specific operation.</td></tr></tbody></table></div></div><p><br class="table-break">
</p><p>
The 'result' property is reusable.
</p>
The Math task supports nested "Op" elements. An Op element represents single mathematical operation, such as "min" or "add".
<p>
</p><div class="table"><a name="idp62553168"></a><p class="title"><b>Table 15.2. Op Attributes</b></p><div class="table-contents"><table summary="Op Attributes" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td>op</td><td>Set the name of this operation. Allowed values are
one of the method names from java.lang.Math or java.lang.StrictMath, or one of "add", "subtract", "multiply", "divide", or "mod" (or "+", "-", "*", "/", or "%", respectively)</td><td>None</td><td>Yes</td></tr><tr><td>datatype</td><td>Sets the datatype of this calculation. Allowed values are
"int", "long", "float", or "double". Optional, default
is "double". If the parent Math task has a datatype set, this value will be ignored and the datatype specifed in the task will be used.</td><td>"int"</td><td>No</td></tr></tbody></table></div></div><p><br class="table-break">
</p><p>
The Op element supports nested "Op" elements and nested "Num" elements. A Num represents a number. When an Op is nested in another Op, the nested Op is treated as a Num. The nested elements can be any combination of Op or Num as appropriate for the formula being calculated. Most of the operations provided by java.lang.Math and java.lang.StrictMath operate on one or two numbers. The "+", "-", "*", "/", and "%" operations can task any number of nested numbers.
</p><p>
</p><div class="table"><a name="idp62563808"></a><p class="title"><b>Table 15.3. Num Attributes</b></p><div class="table-contents"><table summary="Num Attributes" border="1"><colgroup><col><col><col><col></colgroup><thead><tr><th>Attribute</th><th>Description</th><th>Default</th><th>Required</th></tr></thead><tbody><tr><td>value</td><td>Set the value for this number. Must be able to parse to the datatype set by the parent element or the default datatype set by the task. Two special numbers, pi and e, can be represented by PI and E respectively. ("PI" is the ratio of the diameter of a circle to its radius, "E" is Euler's e, the base for natural logrithms.)</td><td>None</td><td>Yes</td></tr><tr><td>datatype</td><td>Sets the datatype of this number. Allowed values are
"int", "long", "float", or "double". Optional, default
is "double". If the parent Math task has a datatype set, this value will be ignored and the datatype specifed in the task will be used.</td><td>double</td><td>No</td></tr></tbody></table></div></div><p><br class="table-break">
</p><p>
Some examples:
</p><p>
</p><pre class="programlisting">
<var name="op1" value="12"/>
<var name="op2" value="6"/>
<var name="op" value="+"/>
<!-- demo plus -->
<math result="result" operand1="${op1}" operation="${op}" operand2="${op2}" datatype="int"/>
<echo>${op1} ${op} ${op2} = ${result}</echo>
<assert name="result" value="18"/>
<!-- demo reusing result -->
<math result="result" operand1="${result}" operation="${op}" operand2="${op2}" datatype="int"/>
<echo>${op1} ${op} ${op2} = ${result}</echo>
<assert name="result" value="24"/>
<!-- demo minus -->
<var name="op" value="-"/>
<math result="result" operand1="${op1}" operation="${op}" operand2="${op2}" datatype="int"/>
<echo>${op1} ${op} ${op2} = ${result}</echo>
<assert name="result" value="6"/>
<!-- demo multiply -->
<var name="op" value="*"/>
<math result="result" operand1="${op1}" operation="${op}" operand2="${op2}" datatype="int"/>
<echo>${op1} ${op} ${op2} = ${result}</echo>
<assert name="result" value="72"/>
<!-- demo divide -->
<var name="op" value="/"/>
<math result="result" operand1="${op1}" operation="${op}" operand2="${op2}" datatype="int"/>
<echo>${op1} ${op} ${op2} = ${result}</echo>
<assert name="result" value="2"/>
<!-- demo modulo -->
<var name="op" value="%"/>
<math result="result" operand1="${op1}" operation="${op}" operand2="${op2}" datatype="int"/>
<echo>${op1} ${op} ${op2} = ${result}</echo>
<assert name="result" value="0"/>
<!-- demo calculating the area of a circle -->
<!-- first, calculate the radius -->
<math result="radius"> <!-- defaults to double datatype -->
<op type="*">
<num value="1"/>
<num value="2"/>
<num value="3"/>
<num value="4"/>
<num value="5"/>
</op>
</math>
<echo> 1 * 2 * 3 * 4 * 5 = ${radius}</echo>
<!-- now calculate the area -->
<math result="area" precision="float">
<op type="*">
<num value="PI"/>
<op type="pow">
<num value="${radius}"/>
<num value="2"/>
</op>
</op>
</math>
<echo>area = PI * radius ^ 2 = ${area}</echo>
<!-- demo calculating a random number between 0 and 100 -->
<math result="result">
<op op="rint">
<op op="*">
<num value="100"/>
<op op="random"/>
</op>
</op>
</math>
<echo>a random number between 0 and 100: ${result}</echo>
<!-- demo another multiplication -->
<math result="result" operation="multiply" operand1="17" operand2="13"/>
<echo>${result}</echo>
</pre><p>
</p></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="bk03ch14.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="bk03.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="bk03ch16.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Chapter 14. UID </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> Chapter 16. Hostname</td></tr></table></div></body></html>
|