<?xml version="1.0" encoding="utf-8"?>
<s1 title="Math"><p>The following functions can be used to perform arithmetic on objects and variables. </p>
<p>These should be written in the following formats: </p>
<ul><li><p><em>variable.method(arguments), example - ... </em> </p>
</li>
<li><p><em>object.method(arguments), example - ... </em> </p>
</li>
</ul>
<p>Click each method name in the table below for more details of it, with examples. </p>
<p><strong>Functions</strong> </p>
<table><strong class="highlight"><![CDATA[]]></strong><tr><td><strong class="highlight"><![CDATA[]]></strong><p><strong>Function </strong> </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p><strong>Type</strong> </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p><strong>Description </strong> </p>
</td><td><strong class="highlight"><![CDATA[]]></strong><p> </p>
</td></tr><tr><td><p><jump href="/wiki/Math#a">abs</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns an absolute value for the number specified by the parameter val. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#a">acos</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns the arc cosine of the number specified in the parameter val, in radians. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#a">asin</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns the arc sine for the number specified in the parameter val, in radians. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#a">atan</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns the value, in radians, of the angle whose tangent is specified in the parameter val. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#a">atan2</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns the angle of the point y/x in radians, when measured counterclockwise from a circle&apos;s x axis (where 0,0 represents the center of the circle). </p>
</td></tr><tr><td><p><jump href="/wiki/Math#c">ceil</jump> </p>
</td><td><p>int </p>
</td><td><p>Returns the ceiling of the specified number or expression. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#c">cos</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns the cosine of the specified angle in radians. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#e">exp</jump> </p>
</td><td><p>int </p>
</td><td><p>Returns the value of the base of the natural logarithm (e), to the power of the exponent specified in the parameter x. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#f">floor</jump> </p>
</td><td><p>int </p>
</td><td><p>Returns the floor of the number or expression specified in the parameter val. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#l">log</jump> </p>
</td><td><p>int </p>
</td><td><p>Returns the natural logarithm of the parameter val. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#m">max</jump> </p>
</td><td><p>int </p>
</td><td><p>Evaluates val1 and val2 (or more values) and returns the largest value. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#m">min</jump> </p>
</td><td><p>int </p>
</td><td><p>Evaluates val1 and val2 (or more values) and returns the smallest value. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#p">pow</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns base to the power of pow. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#r">random</jump> </p>
</td><td><p>int </p>
</td><td><p>Returns a pseudo-random number n, where 0 &lt;= n &lt; 1. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#r">round</jump> </p>
</td><td><p>int </p>
</td><td><p>Rounds the value of the parameter val up or down to the nearest integer and returns the value. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#s">sin</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns the sine of the specified angle in radians. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#s">sqrt</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns the square root of the specified number. </p>
</td></tr><tr><td><p><jump href="/wiki/Math#t">tan</jump> </p>
</td><td><p>int </p>
</td><td><p>Computes and returns the tangent of the specified angle. </p>
</td></tr></table><p></p>
<s2 id="abs" title="abs">
<p><strong>Usage:</strong> abs(number) </p>
<p>Computes and returns an absolute value for the number specified by the parameter val. </p>
<p><strong>Example:</strong> </p>
<p>echo abs(-123456) </p>
<p>echo abs(123456) </p>
<p><strong>Result:</strong> </p>
<p>123456 </p>
<p>123456 </p>
<ul><li></li>
</ul>
<p></p>
</s2>
<s2 id="acos" title="acos">
<p><strong>Usage:</strong> acos(number.decimal) </p>
<p>Computes and returns the arc cosine of the number specified in the parameter val, in radians. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo acos(0.75) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 0.7227342478134157 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="asin" title="asin">
<p><strong>Usage:</strong> asin(number.decimal) </p>
<p>Computes and returns the arc sine for the number specified in the parameter val, in radians. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo asin(0.75) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 0.848062078981481 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="atan" title="atan">
<p><strong>Usage:</strong> atan(Number) </p>
<p>Computes and returns the value, in radians, of the angle whose tangent is specified in the parameter val. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo atan(7) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 1.4288992721907328 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="atan2" title="atan2">
<p><strong>Usage:</strong> atan2(FirstNumber, SecondNumber) </p>
<p>Returns a string comprising the characters represented by the Unicode character codes in the parameters. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo atan2(7,3) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 1.1659045405098132 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="ceil" title="ceil">
<p><strong>Usage:</strong> ceil(Number.Decimal) </p>
<p>Returns the ceiling of the specified number or expression. Basically this means return the number rounded up to next whole number </p>
<p><strong>Example:</strong> </p>
<p>echo ceil(4.1) </p>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 5 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="cos" title="cos">
<p><strong>Usage:</strong> cos(angle) </p>
<p>Computes and returns the cosine of the specified angle in radians. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo cos(7) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 0.7539022543433046 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="exp" title="exp">
<p><strong>Usage:</strong> exp(number) </p>
<p>Returns the value of the base of the natural logarithm (e), to the power of the exponent specified in the parameter x. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo exp(7) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 1096.633158428458 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="floor" title="floor">
<p><strong>Usage:</strong> floor(Number.decimal) </p>
<p>Returns the floor of the number or expression specified in the parenthesis... Floor is the whole number part, without the decimals. Basically means chop the decimal portion of the number off. </p>
<p><strong>Example:</strong> </p>
<p>echo floor(1234.56) </p>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 1234 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="pow" title="pow">
<p><strong>Usage:</strong> pow(base, exponent) </p>
<p>Computes and returns base to the power of pow. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo pow(7, 3) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 343 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="max" title="max">
<p><strong>Usage:</strong> max(FirstValue, SecondValue) </p>
<p>Evaluates val1 and val2 (or more values) and returns the largest value. </p>
<p><strong>Example:</strong> </p>
<p>echo max( city.troop.scouter, 100k ) </p>
<p><strong>Result:</strong> </p>
<p>If city.troop.scouter (the current number of scouts in the city) &lt; 100k, then max( city.troop.scouter, 100k ) will return the number of scouts in city. If city.troop.scouter &gt;= 100k then it will return 100000 </p>
<ul><li></li>
</ul>
<p></p>
</s2>
<s2 id="min" title="min">
<p><strong>Usage:</strong> min(FirstValue, SecondValue) </p>
<p>Evaluates val1 and val2 (or more values) and returns the smallest value. </p>
<p><strong>Example:</strong> </p>
<p>echo min(city.resource.food.amount,99999999) </p>
<ul><li></li>
</ul>
<p><strong>Result:</strong> </p>
<p>this will return whichever is smaller, 99,999,999 or the current amount of food in the city </p>
<p></p>
</s2>
<s2 id="random" title="random">
<p><strong>Usage:</strong> random() </p>
<p>Returns a pseudo-random number n, where 0 &lt;= n &lt; 1. </p>
<p><strong>Example:</strong> </p>
<p>echo round(random()*10) </p>
<ul><li></li>
</ul>
<p><strong>Result:</strong> </p>
<p>a random number between 0 and 9 </p>
<ul><li></li>
</ul>
<p></p>
</s2>
<s2 id="round" title="round">
<p><strong>Usage:</strong> round(number.decimal,[optional] places) </p>
<p>Rounds the value of the parameter val up or down to the nearest integer and returns the value. Optional argument to specify precision (or number of decimal places). </p>
<p><strong>Example:</strong> </p>
<p>echo round(6.66666666666666666666) </p>
<p>echo round(6.66666666666666666666,1) </p>
<p>echo round(6.66666666666666666666,2) </p>
<p>echo round(6.66666666666666666666,3) </p>
<ul><li></li>
</ul>
<p><strong>Result:</strong> </p>
<p>7 </p>
<p>6.7 </p>
<p>6.67 </p>
<p>6.667 </p>
<p></p>
</s2>
<s2 id="sin" title="sin">
<p><strong>Usage:</strong> sin(angle) </p>
<p>Computes and returns the sine of the specified angle in radians. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo sin(3) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 0.1411200080598672 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="sqrt" title="sqrt">
<p><strong>Usage:</strong> sqrt(number) </p>
<p>Computes and returns the square root of the specified number. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo sqrt(16) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 4 (City Name) - Script stopped </li>
</ul>
<p></p>
</s2>
<s2 id="tan" title="tan">
<p><strong>Usage:</strong> tan(angle) </p>
<p>Computes and returns the tangent of the specified angle. </p>
<p><strong>Example:</strong> </p>
<ul><li>echo tan(4) </li>
</ul>
<p><strong>Result:</strong> </p>
<ul><li>(City Name) - 1.1578212823495775 </li>
</ul>
<p>(City Name) - Script stopped </p>
<p></p>

<br/>------------------------------------------------------------------------------<br/>
<p> </p>

<br/>------------------------------------------------------------------------------<br/>
<p> <jump href="/wiki/CategoryFunctions">CategoryFunctions</jump> </p>
</s2></s1>