\section{Arithmetic And Expressions}
\label{Arithmetic And Expressions}

     The numeric argument of a TECO command may consist  of  a  single
     integer,  any of the characters listed in 
	Table~\ref{Characters Associated With Numeric Quantities}, the numeric
     contents of any Q-register, or an arithmetic combination of these
     elements.   If  an arithmetic expression is supplied as a numeric
     argument, TECO will  evaluate  the  expression.   All  arithmetic
     expressions are evaluated from left to right without any operator
     precedence.  Parentheses may be used to override the normal order
     of  evaluation  of  an  expression.  If parentheses are used, all
     operations within the parentheses are performed, left  to  right,
     before  operations  outside  the parentheses.  Parentheses may be
     nested, in which  case  the  innermost  expression  contained  by
     parentheses  will  be  evaluated first.  Table~\ref{Arithmetic Operators} 
	lists all of
     the  arithmetic  operators  that  may  be  used   in   arithmetic
     expressions.


\begin{table}[h]
\caption{\bf Arithmetic Operators}
\label{Arithmetic Operators}
\end{table}
\nopagebreak

\begin{tabular}{lll}
\multicolumn{1}{c}{OPERATOR}  & 
	\multicolumn{1}{c}{EXAMPLE} & 
	\multicolumn{1}{c}{FUNCTION} \\

     {\tt +}   & {\tt +2=2}      & Ignored if used before the first term  in  an \\
               &                 & expression. \\

     {\tt +}   & {\tt 5+6=11}    & Addition, if used between terms. \\

     {\tt -}   & {\tt -2=-2}     & Negation, if used before the first term in an \\
               &                 & expression. \\

     {\tt -}   & {\tt 8-2=6}     & Subtraction, if used between terms \\

     {\tt *}   & {\tt 8*2=16}    & Multiplication.  Used between terms. \\

     {\tt /}   & {\tt 8/3=2}     & Integer division with loss of the  remainder. \\
               &                 & Used between terms. \\

     {\tt \&}        & {\tt 12\&10=8}   & Bitwise   logical   AND   of    the    binary \\
               &          & representation   of   the  two  terms.   Used \\
               &          & between the terms. \\

     {\tt \#}         & {\tt 12\#10=14}  & Bitwise logical OR of the binary of  the  two \\
               &          & terms.  Used between the terms. \\

     \caret {\tt \_}  &      & {\tt 5}\caret {\tt \_=-6}    Unary  one's  complement.   Used   after   an \\
               &          & expression.   This  is  a  TECO  command that \\
               &          & complements its argument.  Strictly speaking, \\
               &          & it is not a unary operator. \\
\end{tabular}

\begin{table}[h]
\caption{\bf Conversion And Radix Control Commands}
\label{Conversion And Radix Control Commands}
\end{table}
\nopagebreak

\begin{list}{}{\labelsep 20pt}

     \item[{\em COMMAND}]        {\em FUNCTION}

     \item[{\tt n=}]         This command causes the value of {\tt n} to be 
		output at  the 
               terminal  in  decimal followed by a carriage return and 
               line feed.  Decimal numeric conversion is signed.   For 
               example, the unsigned number 65535 will output as -1 on 
               TECO-11.  TECO's radix is unaltered. 

  \item[{\tt n==}]        This command causes the value of {\tt n} to be 
	output at  the 
               terminal  in  octal  (base  8)  followed  by a carriage 
               return and line  feed.   Octal  numeric  conversion  is 
               unsigned.    For  example,  the  unsigned  number  8191 
               (decimal) will output as 17777 on TECO-8.  TECO's radix 
               is unaltered. 

\iftecoelevenonly
     \item[{\tt n===}]       This command causes the value of {\tt n} to 
	be output at  the 
               terminal   in  hexadecimal  (base  16)  followed  by  a 
               carriage return and line feed.  Hexadecimal  output  is 
               unsigned.  TECO's radix is unaltered. 
               {\em [TECO-11 only]} 
\fi

     \item[{\tt n:=}]        
     \item[{\tt n:==}]       
     \item[{\tt n:===}]      These commands are equivalent to  {\tt n=},  
	{\tt n==},  and  {\tt n===}, 
               except  that  they leave the carriage positioned at the 
               end of the output. 

     \item[\caret {\tt O}]         {\tt <CTRL/O>} (caret/O) causes all 
	subsequent numeric  input 
               to  be  accepted as octal numbers.  Numeric conversions 
               using the \bs or {\tt n}\bs commands will  also  
	be  octal.   
	The 
               digits  8  and  9 become illegal as numeric characters. 
               The octal radix will continue to be used until the next 
               \caret {\tt D} command is executed or until TECO's radix 
	is changed 
               by an {\tt n}\caret {\tt R} command. 
               {\em NOTE:   On  TECO-10,  this  command  only  affects  the 
               immediately following digit string.} 

\ifnotintecoten
     \item[\caret {\tt D}]         {\tt <CTRL/D>} (\caret{\tt D}) causes 
		all subsequent numeric  input to be accepted as decimal 
		numbers.  This is the initial setting. 
               {\em [Not in TECO-10]} 
\fi

\iftecoelevenonly
     \item[\caret{\tt R}]         This command returns the binary value of 
			TECO's current radix. 
               {\em [TECO-11 only]} 
\fi

     \item[{\tt n}\caret{\tt R}]        This command sets TECO's radix 
	to the value of  {\tt n}.   It 
               is  currently  implemented only in TECO-11, where {\tt n} may 
               only be one of the values 8, 10,  or  16  (representing 
               octal  mode,  decimal mode, or hexadecimal mode).  If {\tt n}
               is not  one  of  these  values,  TECO's  radix  remains 
               unchanged and the {\tt ?IRA} error message is produced. 

     \item[{\tt \bs}]          A backslash  character  which  is  not  
	preceded  by  a 
               numeric  argument  causes  TECO  to  evaluate the digit 
               string  (if   any)   beginning   with   the   character 
               immediately  following the buffer pointer and ending at 
               the next character that is not valid  for  the  current 
               radix.   The  value becomes the numeric argument of the 
               next command.  The first character may be a digit or  {\tt +} 
               or  {\tt -}.   As  the  backslash  command is evaluated, TECO 
               moves the buffer  pointer  to  a  position  immediately 
               following  the  digit  string.   If  there  is no digit 
               string following the pointer, the result  is  zero  and 
               the  pointer  position  remains  unchanged.   Except on 
               TECO-8, the digits 8 and 9 will stop the evaluation  if 
               TECO's current radix is octal. 

     \item[{\tt n\bs}]         The backslash command preceded by an  argument  inserts 
               the  value  of  {\tt n}  into  the text buffer at the current 
               position of the pointer, leaving the pointer positioned 
               after  the  last digit of the insertion.  The insertion 
               is either  signed  decimal  (decimal  radix),  unsigned 
               octal    (octal   radix),   or   unsigned   hexadecimal 
               (hexadecimal radix).  Note that \bs is a  
		{\em bidirectional} 
               command.   {\tt \bs}  inserts  a  string into text while 
		\bs (no argument) returns a numeric result. 
\end{list}

