blob: 0434e26afb7b85b6085f0c0384d206453c99f4f7 [file] [log] [blame]
<html><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Addition and Subtraction:</title><link href="book.css" rel="stylesheet" type="text/css"><link href="../book.css" rel="stylesheet" type="text/css"><meta content="DocBook XSL Stylesheets V1.74.0" name="generator"><link rel="home" href="index.html" title="XPath 2.0 Processor User Manual"><link rel="up" href="ch02s03s05.html" title="Arithmetic Expressions"><link rel="prev" href="ch02s03s05s02.html" title="Multiplication and Division:"><link rel="next" href="ch02s03s06.html" title="Range expressions"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="section" lang="en"><div class="titlepage"><div><div><h4 class="title"><a name="Addition_and_Subtraction:"></a>Addition and Subtraction:</h4></div></div></div><p>The operators <span class="bold"><strong>+</strong></span> and <span class="italic">'-'</span> perform addition and subtraction of
numbers, in the usual way. Once again, if the operands are of
different types, XPath 2.0 specifications say one of them is
promoted but numeric type promotion is currently unsupported by
PsychoPath. The result is of the same type as the operands.</p><p>Examples of above would be:</p><p><pre class="programlisting"> -(5 + 7)</pre></p><p> <span class="bold"><strong>result:</strong></span></p><div class="orderedlist"><ol type="1"><li><p>xs:integer: -12</p></li></ol></div><p><pre class="programlisting">-xs:float(&rsquo;1.23&rsquo;)</pre></p><p> <span class="bold"><strong>result:</strong></span></p><div class="orderedlist"><ol type="1"><li><p>xs:float: -1.23</p></li></ol></div><p><pre class="programlisting">-xs:double(&rsquo;1.23&rsquo;)</pre></p><p> <span class="bold"><strong>result:</strong></span></p><div class="orderedlist"><ol type="1"><li><p>xs:double: -1.23</p></li></ol></div><p><pre class="programlisting">(+5 - +7)</pre></p><p> <span class="bold"><strong>result:</strong></span></p><div class="orderedlist"><ol type="1"><li><p>xs:integer: -2</p></li></ol></div><p><pre class="programlisting">(1 to 5 div 0 )</pre></p><p> <span class="bold"><strong>result:</strong></span></p><div class="itemizedlist"><ul type="disc"><li><p>FAIL (division by zero!)</p></li></ul></div><p><pre class="programlisting">5*6*10*5*96 div 20 div 3 div 1</pre></p><p> <span class="bold"><strong>result:</strong></span></p><div class="orderedlist"><ol type="1"><li><p>xs:decimal: 2400.0</p></li></ol></div><p><pre class="programlisting">31 mod 15</pre></p><p> <span class="bold"><strong>result:</strong></span></p><div class="orderedlist"><ol type="1"><li><p>xs:integer: 1</p></li></ol></div></div></body></html>