aboutsummaryrefslogtreecommitdiff
path: root/src/hyper/pages/SINT.ht
diff options
context:
space:
mode:
Diffstat (limited to 'src/hyper/pages/SINT.ht')
-rw-r--r--src/hyper/pages/SINT.ht116
1 files changed, 116 insertions, 0 deletions
diff --git a/src/hyper/pages/SINT.ht b/src/hyper/pages/SINT.ht
new file mode 100644
index 00000000..fdadf644
--- /dev/null
+++ b/src/hyper/pages/SINT.ht
@@ -0,0 +1,116 @@
+% Copyright The Numerical Algorithms Group Limited 1992-94. All rights reserved.
+% !! DO NOT MODIFY THIS FILE BY HAND !! Created by ht.awk.
+\newcommand{\SingleIntegerXmpTitle}{SingleInteger}
+\newcommand{\SingleIntegerXmpNumber}{9.72}
+%
+% =====================================================================
+\begin{page}{SingleIntegerXmpPage}{9.72 SingleInteger}
+% =====================================================================
+\beginscroll
+
+%%
+%% SINT.htex
+%%
+%%
+The \axiomType{SingleInteger} domain is intended to provide support
+%-% \HDindex{integer!machine}{SingleIntegerXmpPage}{9.72}{SingleInteger}
+in \Language{} for machine integer arithmetic.
+It is generally much faster than (bignum) \axiomType{Integer} arithmetic
+but suffers from a limited range of values.
+Since \Language{} can be implemented on top of various
+dialects of Lisp, the actual representation of small integers
+may not correspond exactly to the host machines integer representation.
+
+In the CCL implementation of AXIOM (Release 2.1 onwards) the underlying
+representation of \axiomType{SingleInteger} is the same as \axiomType{Integer}.
+The underlying Lisp primitives treat machine-word sized computations
+specially.
+
+%Under \spadgloss{AKCL} on the IBM Risc System/6000,
+%small integers are restricted
+%to the range \texht{$-{2^{26}}$}{\spad{-2**26}} to
+%\texht{${2^{26}}-1$}{\spad{2**26 - 1}},
+%allowing 1 bit for overflow detection.
+
+\xtc{
+You can discover the minimum and maximum values in your implementation
+by using \spadfunFrom{min}{SingleInteger} and \spadfunFrom{max}{SingleInteger}.
+}{
+\spadpaste{min()\$SingleInteger}
+}
+\xtc{
+}{
+\spadpaste{max()\$SingleInteger}
+}
+\xtc{
+To avoid confusion with \axiomType{Integer}, which is the default
+type for integers, you usually need to work with declared variables
+(\downlink{``\ugTypesDeclareTitle''}{ugTypesDeclarePage} in Section \ugTypesDeclareNumber\ignore{ugTypesDeclare}) \ldots
+}{
+\spadpaste{a := 1234 :: SingleInteger \bound{a}}
+}
+\xtc{
+or use package calling
+(\downlink{``\ugTypesPkgCallTitle''}{ugTypesPkgCallPage} in Section \ugTypesPkgCallNumber\ignore{ugTypesPkgCall}).
+}{
+\spadpaste{b := 124\$SingleInteger \bound{b}}
+}
+\xtc{
+You can add, multiply and subtract \axiomType{SingleInteger} objects,
+and ask for the greatest common divisor (\spadfun{gcd}).
+}{
+\spadpaste{gcd(a,b) \free{a}\free{b}}
+}
+\xtc{
+The least common multiple (\spadfun{lcm}) is also available.
+}{
+\spadpaste{lcm(a,b) \free{a}\free{b}}
+}
+
+\xtc{
+Operations \spadfunFrom{mulmod}{SingleInteger},
+\spadfunFrom{addmod}{SingleInteger},
+\spadfunFrom{submod}{SingleInteger}, and
+\spadfunFrom{invmod}{SingleInteger} are similar---they provide
+arithmetic modulo a given small integer.
+Here is \spad{5 * 6 {\tt mod} 13}.
+}{
+\spadpaste{mulmod(5,6,13)\$SingleInteger}
+}
+\xtc{
+To reduce a small integer modulo a prime, use \spadfunFrom{positiveRemainder}{SingleInteger}.
+}{
+\spadpaste{positiveRemainder(37,13)\$SingleInteger}
+}
+\xtc{
+Operations
+\spadfunFrom{And}{SingleInteger},
+\spadfunFrom{Or}{SingleInteger},
+\spadfunFrom{xor}{SingleInteger},
+and \spadfunFrom{Not}{SingleInteger}
+provide bit level operations on small integers.
+}{
+\spadpaste{And(3,4)\$SingleInteger}
+}
+\xtc{
+Use
+\spad{shift(int,numToShift)} to shift bits, where
+\spad{i} is shifted left if \spad{numToShift} is positive, right
+if negative.
+}{
+\spadpaste{shift(1,4)\$SingleInteger}
+}
+\xtc{
+}{
+\spadpaste{shift(31,-1)\$SingleInteger}
+}
+
+Many other operations are available for small integers, including
+many of those provided for \axiomType{Integer}.
+To see the other operations, use the Browse \HyperName{} facility
+(\downlink{``\ugBrowseTitle''}{ugBrowsePage} in Section \ugBrowseNumber\ignore{ugBrowse}).
+\showBlurb{SingleInteger}.
+\endscroll
+\autobuttons
+\end{page}
+%