Added numerics

This commit is contained in:
2023-03-29 11:25:08 +02:00
parent f011e5efff
commit 6f25f2456d

View File

@@ -454,7 +454,7 @@
<td>l:library</td>
</tr>
</table><br>
<a href=https://www.w3.org/TR/xquery-operators/#func-name" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
<a href="https://www.w3.org/TR/xquery-operators/#func-name" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
@@ -530,7 +530,7 @@
</tr>
</table><br>
<a href=https://www.w3.org/TR/xquery-operators/#func-nilled" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
<a href="https://www.w3.org/TR/xquery-operators/#func-nilled" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
@@ -756,9 +756,234 @@
</tr>
</table>
<b>Return type:</b> xs:double<br><br>
<a href=https://www.w3.org/TR/xquery-operators/#func-number" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
<a href="https://www.w3.org/TR/xquery-operators/#func-number" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:abs()</code></a>
<div class="content">
Returns the absolute value of $arg. If $arg is negative returns -$arg otherwise returns $arg. If type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.<br>
For xs:float and xs:double arguments, if the argument is positive zero or negative zero, then positive zero is returned. If the argument is positive or negative infinity, positive infinity is returned.<br>
For detailed type semantics, see Section 7.2.3 The fn:abs, fn:ceiling, fn:floor, fn:round, and fn:round-half-to-even functions.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>numeric?</td>
<td>$arg</td>
</tr>
</table>
<b>Return type:</b> numeric?<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>abs(-2)</td>
<td>2</td>
</tr>
<tr>
<td>abs(2137)</td>
<td>2137</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-abs" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:ceiling()</code></a>
<div class="content">
Returns the smallest (closest to negative infinity) number with no fractional part that is not less than the value of $arg. If type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.<br>
For xs:float and xs:double arguments, if the argument is positive zero, then positive zero is returned. If the argument is negative zero, then negative zero is returned. If the argument is less than zero and greater than -1, negative zero is returned.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>numeric?</td>
<td>$arg</td>
</tr>
</table>
<b>Return type:</b> numeric?<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>ceiling(10.5)</td>
<td>11</td>
</tr>
<tr>
<td>ceiling(-10.5)</td>
<td>-10</td>
</tr>
<tr>
<td>ceiling(10.1)</td>
<td>11</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-ceiling" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:floor()</code></a>
<div class="content">
Returns the largest (closest to positive infinity) number with no fractional part that is not greater than the value of $arg. If type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.<br>
For float and double arguments, if the argument is positive zero, then positive zero is returned. If the argument is negative zero, then negative zero is returned.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>numeric?</td>
<td>$arg</td>
</tr>
</table>
<b>Return type:</b> numeric?<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>floor(10.5)</td>
<td>10</td>
</tr>
<tr>
<td>floor(-10.5)</td>
<td>-11</td>
</tr>
<tr>
<td>floor(10.8)</td>
<td>10</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-floor" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:round()</code></a>
<div class="content">
Returns the number with no fractional part that is closest to the argument. If there are two such numbers, then the one that is closest to positive infinity is returned. If type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.<br>
For xs:float and xs:double arguments, if the argument is positive infinity, then positive infinity is returned. If the argument is negative infinity, then negative infinity is returned. If the argument is positive zero, then positive zero is returned. If the argument is negative zero, then negative zero is returned. If the argument is less than zero, but greater than or equal to -0.5, then negative zero is returned. In the cases where positive zero or negative zero is returned, negative zero or positive zero may be returned as [XML Schema Part 2: Datatypes Second Edition] does not distinguish between the values positive zero and negative zero.<br>
For the last two cases, note that the result is not the same as fn:floor(x+0.5).<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>numeric?</td>
<td>$arg</td>
</tr>
</table>
<b>Return type:</b> numeric?<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>round(10.5)</td>
<td>11</td>
</tr>
<tr>
<td>round(10.4999)</td>
<td>10</td>
</tr>
<tr>
<td>round(-10.5)</td>
<td>-10</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-round" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
<a href="#" onClick="return false;"
class="hyperlink collapsible collapsibleMini collapseTrigger"><code>fn:round-half-to-even()</code></a>
<div class="content">
The value returned is the nearest (that is, numerically closest) value to $arg that is a multiple of ten to the power of minus $precision. If two such values are equally near (e.g. if the fractional part in $arg is exactly .500...), the function returns the one whose least significant digit is even.<br>
If the type of $arg is one of the four numeric types xs:float, xs:double, xs:decimal or xs:integer the type of the result is the same as the type of $arg. If the type of $arg is a type derived from one of the numeric types, the result is an instance of the base numeric type.<br>
The first signature of this function produces the same result as the second signature with $precision=0.<br>
For arguments of type xs:float and xs:double, if the argument is NaN, positive or negative zero, or positive or negative infinity, then the result is the same as the argument. In all other cases, the argument is cast to xs:decimal, the function is applied to this xs:decimal value, and the resulting xs:decimal is cast back to xs:float or xs:double as appropriate to form the function result. If the resulting xs:decimal value is zero, then positive or negative zero is returned according to the sign of the original argument.<br>
Note that the process of casting to xs:decimal may result in an error [err:FOCA0001].<br>
If $arg is of type xs:float or xs:double, rounding occurs on the value of the mantissa computed with exponent = 0.<br>
<br>
<b>Arguments:</b>
<table class="table-doc">
<tr>
<th>Type</th>
<th>Description</th>
</tr>
<tr>
<td>numeric?</td>
<td>$arg</td>
</tr>
<tr>
<td>numeric?</td>
<td>$precision (Optional)</td>
</tr>
</table>
<b>Return type:</b> numeric?<br><br>
<b>Examples:</b>
<table class="table-doc">
<tr>
<th>Query</th>
<th>Result</th>
</tr>
<tr>
<td>round-half-to-even(0.5)</td>
<td>0</td>
</tr>
<tr>
<td>round-half-to-even(1.5)</td>
<td>2</td>
</tr>
<tr>
<td>round-half-to-even(2.5)</td>
<td>2</td>
</tr>
<tr>
<td>round-half-to-even(2.6)</td>
<td>3</td>
</tr>
</table><br>
<a href="https://www.w3.org/TR/xquery-operators/#func-round-half-to-even" class="hyperlink" target="_blank"><code>W3C Documentation reference</code></a>
</div>
</div>
</div>