Changes

Jump to navigation Jump to search
346 bytes added ,  15:59, 9 March 2023
no edit summary
The math [[Module Library|XQuery Module]] defines functions to perform mathematical operations, such as {{Code|pi}}, {{Code|asin}} and {{Code|acos}}. Most functions are specified in the [httphttps://www.w3.org/TR/xpath-functions-3031/ Functions and Operators Specification] of the upcoming XQuery 3.0 Recommendation, and some additional ones have been added in this module.
=Conventions=
All functions in this module are assigned to the {{Code|<code><nowiki>http://www.w3.org/2005/xpath-functions/math}} </nowiki></code> namespace, which is statically bound to the {{Code|math}} prefix.<br/>
=W3 Functions=
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:pi||() as xs:double}}</pre>
|-
| '''Summary'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:sqrt|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the square root of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the {{Code|xs:double}} value of the mathematical square root of {{Code|$arg}}.
|}
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:sin|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the sine of the {{Code|$arg}}, expressed in radians.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the sine of {{Code|$arg}}, treated as an angle in radians.
|}
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:cos|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the cosine of {{Code|$arg}}, expressed in radians.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the cosine of {{Code|$arg}}, treated as an angle in radians.
|}
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:tan|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the tangent of {{Code|$arg}}, expressed in radians.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the tangent of {{Code|$arg}}, treated as an angle in radians.
|}
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:asin|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the arc sine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc sine of {{Code|$arg}}, returned as an angle in radians in the range -π/2 to +π/2.
|}
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:acos|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the arc cosine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc cosine of {{Code|$arg}}, returned as an angle in radians in the range 0 to +π.
|}
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:atan|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the arc tangent of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc tangent of {{Code|$arg}}, returned as an angle in radians in the range -π/2 to +π/2.
|}
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:atan2|( $arg1 as xs:double?, $arg2 as xs:double|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, the result being in the range -π/2 to +π/2 radians.<br/>If {{Code|$arg1}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the arc tangent of {{Code|$arg1}} divided by {{Code|$arg2}}, returned as an angle in radians in the range -π to +π.
|}
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:pow|( $arg1 as xs:double?, $arg2 as xs:double|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns {{Code|$arg1}} raised to the power of {{Code|$arg2}}.<br/>If {{Code|$arg1}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the {{Code|$arg1}} raised to the power of {{Code|$arg2}}.
|-
| '''Examples'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:exp|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns <i>e</i> raised to the power of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the value of <i>e</i> raised to the power of {{Code|$arg}}.
|-
| '''Examples'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:log|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the natural logarithm of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the natural logarithm (base <i>e</i>) of {{Code|$arg}}.
|-
| '''Examples'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:log10|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the base 10 logarithm of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the base 10 logarithm of {{Code|$arg}}.
|-
| '''Examples'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:e||() as xs:double}}</pre>
|-
| '''Summary'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:sinh|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the hyperbolic sine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic sine of {{Code|$arg}}.
|-
| '''Examples'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:cosh|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the hyperbolic cosine of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic cosine of {{Code|$arg}}.
|-
| '''Examples'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:tanh|( $arg as xs:double?|) as xs:double?}}</pre>
|-
| '''Summary'''
|Returns the hyperbolic tangent of {{Code|$arg}}.<br/>If {{Code|$arg}} is the empty sequence, the empty sequence is returned.<br />Otherwise the result is the hyperbolic tangent of {{Code|$arg}}.
|-
| '''Examples'''
{| width='100%'
|-
| width='90120' | '''SignaturesSignature'''|{{Func|<pre>math:crc32|( $str string as xs:string|?) as xs:hexBinary}}?<br /pre>
|-
| '''Summary'''
|Calculates the CRC32 check sum of the given string {{Code|$strstring}}.<br />If an empty sequence is supplied, the empty sequence is returned.
|-
| '''Examples'''
=Changelog=
 
; Version 9.1
* Updated: {{Function||math:crc32}} can be called with empty sequence.
; Version 7.5
* Moved: {{Code|math:random }} and {{Code|math:uuid }} have been move moved to the [[Random Module]]. 
; Version 7.3
* Added: [[#math:crc32{{Function||math:crc32]] }} and [[#math:uuid{{Function||math:uuid]] }} have been adopted from the obsolete Utility Module. [[Category:XQuery]]
Bureaucrats, editor, reviewer, Administrators
13,554

edits

Navigation menu