docs/reference/language_extensions.xml
author ali <ali@juiblex.co.uk>
Wed Oct 10 22:58:21 2012 +0100 (2012-10-10)
changeset 0 bc8c9a11cbfc
permissions -rw-r--r--
Initial version
ali@0
     1
<?xml version="1.0"?>
ali@0
     2
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
ali@0
     3
               "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
ali@0
     4
[
ali@0
     5
]>
ali@0
     6
<chapter id="language-extensions">
ali@0
     7
  <title>Language Extensions</title>
ali@0
     8
ali@0
     9
  <para>
ali@0
    10
    These language extensions are provided in the following namespace URI:
ali@0
    11
    <screen>
ali@0
    12
http://www.juiblex.co.uk/ns/libxexpr
ali@0
    13
    </screen>
ali@0
    14
    People using this namespace are encouraged to use the libxexpr namespace
ali@0
    15
    prefix.
ali@0
    16
  </para>
ali@0
    17
ali@0
    18
  <sect1 id="libxexpr-pi">
ali@0
    19
    <title>Function &lt;pi&gt;</title>
ali@0
    20
ali@0
    21
    <simplesect>
ali@0
    22
      <title>Synopsis</title>
ali@0
    23
	<para>
ali@0
    24
	  &lt;pi&gt; returns the value of π.
ali@0
    25
	</para>
ali@0
    26
    </simplesect>
ali@0
    27
ali@0
    28
    <simplesect>
ali@0
    29
      <title>Arguments</title>
ali@0
    30
	<para>
ali@0
    31
	  &lt;pi&gt; takes no arguments.
ali@0
    32
	</para>
ali@0
    33
    </simplesect>
ali@0
    34
ali@0
    35
    <simplesect>
ali@0
    36
      <title>Return Values</title>
ali@0
    37
	<para>
ali@0
    38
	  &lt;pi&gt; returns the value of π.
ali@0
    39
	</para>
ali@0
    40
    </simplesect>
ali@0
    41
ali@0
    42
    <example>
ali@0
    43
      <programlisting>
ali@0
    44
&lt;libxexpr:pi/&gt; ≅ &lt;float&gt;3.14&lt;/float&gt;<!--
ali@0
    45
   --></programlisting>
ali@0
    46
    </example>
ali@0
    47
  </sect1>
ali@0
    48
ali@0
    49
  <sect1 id="libxexpr-sin">
ali@0
    50
    <title>Function &lt;sin&gt;</title>
ali@0
    51
ali@0
    52
    <simplesect>
ali@0
    53
      <title>Synopsis</title>
ali@0
    54
	<para>
ali@0
    55
	  &lt;sin&gt; computes the sine function.
ali@0
    56
	</para>
ali@0
    57
    </simplesect>
ali@0
    58
ali@0
    59
    <simplesect>
ali@0
    60
      <title>Arguments</title>
ali@0
    61
	<para>
ali@0
    62
	  &lt;sin&gt; takes one argument: x. If no argument is given, an error
ali@0
    63
	  occurs.
ali@0
    64
	</para>
ali@0
    65
    </simplesect>
ali@0
    66
ali@0
    67
    <simplesect>
ali@0
    68
      <title>Return Values</title>
ali@0
    69
	<para>
ali@0
    70
	  &lt;sin&gt; returns the sine of its argument, given in radians.
ali@0
    71
	  If the argument does not evaluate to a finite number,
ali@0
    72
	  &lt;sin&gt; returns an indeterminate result.
ali@0
    73
	</para>
ali@0
    74
    </simplesect>
ali@0
    75
ali@0
    76
    <example>
ali@0
    77
      <programlisting>
ali@0
    78
&lt;libxexpr:sin&gt;
ali@0
    79
  &lt;divide&gt;
ali@0
    80
    &lt;libxexpr:pi/&gt;
ali@0
    81
    2
ali@0
    82
  &lt;/divide&gt;
ali@0
    83
&lt;/libxexpr:sin&gt; --> &lt;float&gt;1&lt;/float&gt;<!--
ali@0
    84
   --></programlisting>
ali@0
    85
    </example>
ali@0
    86
  </sect1>
ali@0
    87
ali@0
    88
  <sect1 id="libxexpr-atan">
ali@0
    89
    <title>Function &lt;atan&gt;</title>
ali@0
    90
ali@0
    91
    <simplesect>
ali@0
    92
      <title>Synopsis</title>
ali@0
    93
	<para>
ali@0
    94
	  &lt;atan&gt; computes the arc tangent function.
ali@0
    95
	</para>
ali@0
    96
    </simplesect>
ali@0
    97
ali@0
    98
    <simplesect>
ali@0
    99
      <title>Arguments</title>
ali@0
   100
	<para>
ali@0
   101
	  &lt;atan&gt; takes two arguments: x and y. The y argument defaults to
ali@0
   102
	  1. If the x argument is missing, an error occurs.
ali@0
   103
	</para>
ali@0
   104
    </simplesect>
ali@0
   105
ali@0
   106
    <simplesect>
ali@0
   107
      <title>Return Values</title>
ali@0
   108
	<para>
ali@0
   109
	  &lt;atan&gt; returns the principal value of the arc tangent of its
ali@0
   110
	  argument(s) in radians. If either argument is indeterminate,
ali@0
   111
	  the result is also indeterminate.
ali@0
   112
	</para>
ali@0
   113
	
ali@0
   114
	<para>
ali@0
   115
	  If two arguments are given, &lt;atan&gt; returns the arc tangent of
ali@0
   116
	  y/x, using the signs of the two arguments to determine the quadrant
ali@0
   117
	  of the result which will be in the range [-π, π]. If both arguments
ali@0
   118
	  are 0, the result will also be 0.
ali@0
   119
	</para>
ali@0
   120
ali@0
   121
	<para>
ali@0
   122
	  If only one argument is given, &lt;atan&gt; returns the arc tangent of
ali@0
   123
	  its argument. The result will be in the range [-π/2, π/2].
ali@0
   124
	</para>
ali@0
   125
    </simplesect>
ali@0
   126
ali@0
   127
    <example>
ali@0
   128
      <programlisting>
ali@0
   129
&lt;libxexpr:atan&gt;1 0&lt;/libxexpr:atan&gt; --> &lt;float&gt;0&lt;/float&gt;<!--
ali@0
   130
   --></programlisting>
ali@0
   131
    </example>
ali@0
   132
  </sect1>
ali@0
   133
ali@0
   134
  <sect1 id="libxexpr-exp">
ali@0
   135
    <title>Function &lt;exp&gt;</title>
ali@0
   136
ali@0
   137
    <simplesect>
ali@0
   138
      <title>Synopsis</title>
ali@0
   139
	<para>
ali@0
   140
	  &lt;exp&gt; computes the base-e exponential function.
ali@0
   141
	</para>
ali@0
   142
    </simplesect>
ali@0
   143
ali@0
   144
    <simplesect>
ali@0
   145
      <title>Arguments</title>
ali@0
   146
	<para>
ali@0
   147
	  &lt;exp&gt; takes zero or one argument: x.
ali@0
   148
	</para>
ali@0
   149
    </simplesect>
ali@0
   150
ali@0
   151
    <simplesect>
ali@0
   152
      <title>Return Values</title>
ali@0
   153
	<para>
ali@0
   154
	  &lt;exp&gt; returns the value of e (the base of natural logarithms)
ali@0
   155
	  raised to the power of its argument (or just e if no argument is
ali@0
   156
	  supplied). If the argument does not evaluate to a finite number,
ali@0
   157
	  &lt;exp&gt; returns an indeterminate result.
ali@0
   158
	</para>
ali@0
   159
    </simplesect>
ali@0
   160
ali@0
   161
    <example>
ali@0
   162
      <programlisting>
ali@0
   163
&lt;libxexpr:exp&gt;2&lt;/libxexpr:exp&gt; ≅ &lt;float&gt;7.389&lt;/float&gt;<!--
ali@0
   164
   --></programlisting>
ali@0
   165
    </example>
ali@0
   166
  </sect1>
ali@0
   167
ali@0
   168
  <sect1 id="libxexpr-log">
ali@0
   169
    <title>Function &lt;log&gt;</title>
ali@0
   170
ali@0
   171
    <simplesect>
ali@0
   172
      <title>Synopsis</title>
ali@0
   173
	<para>
ali@0
   174
	  &lt;log&gt; computes the natural logarithmic function.
ali@0
   175
	</para>
ali@0
   176
    </simplesect>
ali@0
   177
ali@0
   178
    <simplesect>
ali@0
   179
      <title>Arguments</title>
ali@0
   180
	<para>
ali@0
   181
	  &lt;log&gt; takes one argument: x. If no argument is given, an error
ali@0
   182
	  occurs.
ali@0
   183
	</para>
ali@0
   184
    </simplesect>
ali@0
   185
ali@0
   186
    <simplesect>
ali@0
   187
      <title>Return Values</title>
ali@0
   188
	<para>
ali@0
   189
	  &lt;log&gt; returns the natural logarithm of its argument.
ali@0
   190
	  If the argument does not evaluate to a positive finite number,
ali@0
   191
	  &lt;log&gt; returns an indeterminate result.
ali@0
   192
	</para>
ali@0
   193
    </simplesect>
ali@0
   194
ali@0
   195
    <example>
ali@0
   196
      <programlisting>
ali@0
   197
&lt;libxexpr:log&gt;
ali@0
   198
  &lt;libxexpr:exp&gt;2&lt;/libxexpr:exp&gt;
ali@0
   199
&lt;/libxexpr:log&gt; --> &lt;float&gt;2&lt;/float&gt;<!--
ali@0
   200
   --></programlisting>
ali@0
   201
    </example>
ali@0
   202
  </sect1>
ali@0
   203
ali@0
   204
  <sect1 id="libxexpr-pow">
ali@0
   205
    <title>Function &lt;pow&gt;</title>
ali@0
   206
ali@0
   207
    <simplesect>
ali@0
   208
      <title>Synopsis</title>
ali@0
   209
	<para>
ali@0
   210
	  &lt;pow&gt; computes the value of its first argument raised to the
ali@0
   211
	  power of its second argument.
ali@0
   212
	</para>
ali@0
   213
    </simplesect>
ali@0
   214
ali@0
   215
    <simplesect>
ali@0
   216
      <title>Arguments</title>
ali@0
   217
	<para>
ali@0
   218
	  &lt;pow&gt; takes two arguments: x and y. If fewer arguments are
ali@0
   219
	  given, an error occurs.
ali@0
   220
	</para>
ali@0
   221
    </simplesect>
ali@0
   222
ali@0
   223
    <simplesect>
ali@0
   224
      <title>Return Values</title>
ali@0
   225
	<para>
ali@0
   226
	  &lt;pow&gt; returns the value of x (its first argument) raised to the
ali@0
   227
	  power of y (its second argument).
ali@0
   228
	</para>
ali@0
   229
ali@0
   230
	<para>
ali@0
   231
	  If x is a finite value less than 0, and y is a finite non-integer,
ali@0
   232
	  &lt;pow&gt; returns an indeterminate result. 
ali@0
   233
	</para>
ali@0
   234
ali@0
   235
	<para>
ali@0
   236
	  If the result overflows, &lt;pow&gt; returns an indeterminate result. 
ali@0
   237
	</para>
ali@0
   238
ali@0
   239
	<para>
ali@0
   240
	  If result underflows, and is not representable, 0 is returned.
ali@0
   241
	</para>
ali@0
   242
ali@0
   243
	<para>
ali@0
   244
	  Except as specified below, if either argument is indeterminate,
ali@0
   245
	  the result is also indeterminate.
ali@0
   246
	</para>
ali@0
   247
ali@0
   248
	<para>
ali@0
   249
	  If x is 1, the result is 1 (even if y is indeterminate).
ali@0
   250
	</para>
ali@0
   251
ali@0
   252
	<para>
ali@0
   253
	  If y is 0, the result is 1 (even if x is indeterminate).
ali@0
   254
	</para>
ali@0
   255
ali@0
   256
	<para>
ali@0
   257
	  If x is 0, and y is an odd integer greater than 0, the result is 0.
ali@0
   258
	</para>
ali@0
   259
ali@0
   260
	<para>
ali@0
   261
	  If x is 0, and y greater than 0 and not an odd integer, the result
ali@0
   262
	  is 0.
ali@0
   263
	</para>
ali@0
   264
ali@0
   265
	<para>
ali@0
   266
	  If x is 0, and y is less than 0,
ali@0
   267
	  &lt;pow&gt; returns an indeterminate result. 
ali@0
   268
	</para>
ali@0
   269
    </simplesect>
ali@0
   270
ali@0
   271
    <example>
ali@0
   272
      <programlisting>
ali@0
   273
  &lt;libxexpr:pow&gt;10 2&lt;/libxexpr:pow&gt; --> &lt;float&gt;100&lt;/float&gt;<!--
ali@0
   274
   --></programlisting>
ali@0
   275
    </example>
ali@0
   276
  </sect1>
ali@0
   277
</chapter>