% -*-LaTeX-*-
% <BEEBE.EPSILON>TECONUM.LTX.6,  3-Jun-86 10:36:34, Edit by BEEBE
% This is part of TECO.LTX

  Numbers in \TECO{} are integers; floating-point is so rarely
useful in text processing that it is simply not provided.  If
you need to compute a fractional number, you must do it by
appropriate scaling to maintain integer values.  Numbers are
signed values represented in two's-complement notation in one
computer ``word'', which is at least 32 bits wide, even on
microcomputer implementations of \TECO{}.  This is unlikely to
ever pose a restraint on your programming, while 16-bit integers
certainly would.

  A string of digits 0..9 represents a decimal integer, as
usual, and it may have a single optional leading plus or minus
sign, or a \X{complement} operator, \TILDE{}.  Unlike the \C{}
programming language, no significance is attached to leading
zeroes.  Unlike older \TECO's, nothing following a digit
string can change its value.\footnote{Older \TECO's normally
interpret a digit string followed by a period as an octal
value, which requires the interpreter to back up and start over
in the number evaluation.}

   Representation of numbers in other than base 10 is sometimes
convenient.  Instead of changing a global variable containing the
current input radix, a process which turns out to be fraught with
danger in \ETECO{}, this version adopts the notation similar to
that used in the {\sc ada} programming language---an optional
sign, followed by a number base expressed as a {\em decimal}
integer in the range 2..36, followed by a \T{\#} sign,\index{\#}
followed by a ``digit'' string from the set 0..9, A..Z (or a..z,
letter case being insignificant).  Unlike {\sc ada}, we do not
require a trailing \T{\#} sign, since whitespace can always be
used in \TECO{} to separate a number from another token with
which it might otherwise be confused.  For bases larger than 10,
letters count as A $\equiv$ 10, B $\equiv$ 11, \ldots{}, Z
$\equiv$ 36.	 For example,
  \begin{center}
    \begin{small}
      \begin{tabular}{rrrrrrrrr}
\T{127} &
\T{2\#1111111} &
\T{4\#1333} &
\T{8\#177} &
\T{10\#127} &
\T{16\#7f} &
\T{16\#7f} &
\T{32\#3u} &
\T{36\#3i}
      \end{tabular}
    \end{small}
  \end{center}
are all equivalent in value.

Collection of an integer stops at the first
unexpected\label{number-coercion} character, and can never raise
an interpreter error, unless the base is out of range.  Two rules
are applied:
  \begin{itemize}
\item If only a plus or minus sign has been collected, the
      number is $+1$ or $-1$, respectively;
\item Otherwise, if no legal digits have been collected,
      the number is 0.
  \end{itemize}
Thus, we have
  \begin{center}
    \begin{tabular}{rlllll}
    $+$ $\equiv$ & $+1$ & & & &\\
    $-$ $\equiv$ & $-1$ & & & &\\
    36\# $\equiv$ & 35\# $\equiv$ & \ldots & 3\# $\equiv$ & 2\#
	$\equiv$ & 0 
    \end{tabular}
  \end{center}
This means that if the interpreter tries to collect a number and
finds the first character is, say, a letter, the value zero will be
assumed.  This is similar to the \C{} \T{atoi()}
function.  This peculiar behavior is rare, because collection of
a number usually only happens when a decimal digit or sign has
been seen.
