Integers¶
This document describes the Open Dylan implementation of arithmetic functions, especially integer arithmetic. It describes a number of extensions to the Dylan language, which are available from the Dylan library. It also describes a generic arithmetic facility that, through the use of other libraries, allows you to extend arithmetic to special number types, such as “big” (64bit) integers.
Throughout this document, arguments are instances of the class specified
by the argument name (ignoring any numeric suffixes), unless otherwise
noted. Thus, the arguments integer, integer1, and integer2 would
all be instances of the class <integer>
.
The goals of the extensions to the Dylan language described in this document are as follows:
Provide arithmetic operations that are closed over small integers.
This allows type inference to propagate small integer declarations more widely, because there is no possibility of automatic coercion into some more general format.
Make the arithmetic operations that are closed over small integers easily accessible to programmers.
Allow the Dylan library to be described in such a way that only small integers are present by default, moving support for infinite precision integer arithmetic to the BigIntegers library, which must be explicitly used.
Support infinite precision integer arithmetic through the BigIntegers library.
Note
Using that library in another library does not have a negative effect on the correctness or performance of other libraries in the same application that do not use it.
Maintain compatibility with the DRM specification.
In particular, the extensions support the production of efficient code for programs written to be portable with respect to the DRM specification. Use of implementationspecific types or operations in order to get reasonable efficiency is not required. This precludes relegating the
<integer>
class and limited<integer> types to inefficient implementations.Note
When there are several distinct interfaces with the same name but in different modules, the notation interface # module is used in this document to remove ambiguity.
Specify that the class
<integer>
has a finite, implementationdependent range, bounded by the constants$minimuminteger
and$maximuminteger
.The representation for integers must be at least 28 bits, including the sign. That is, the minimum conforming value for
$maximuminteger
is2 ^ 27  1
and the maximum conforming value for$minimuminteger
is2 ^ 27
.Note
Rationale: Restricting
<integer>
in this way allows the programmer to stay in the efficient range without requiring exact knowledge of what that range might be. The full generality of extended precision integers is provided by the BigIntegers library, for programmers who actually need that functionality.Define the type
<machinenumber>
to be the type union of<float>
and<integer>
.
The Dylan library provides implementations of the generic functions and
functions described in this document. If the result of one of these
operations is specified to be an instance of <integer>
and the
mathematically correct result cannot be represented as an <integer>
then an error is signaled. This removes fully generic arithmetic from
the Dylan library. In particular, it removes extended integers, ratios,
and rectangular complex numbers.
Extensions to the dylan Library¶
This section describes the extensions to the Dylan library that provide the arithmetic operations available as standard to your applications. You do not have to explicitly use any additional libraries to have access to any of the functionality described in this section. Note that this section only describes extensions to the Dylan library; for complete descriptions, you should also refer to the Dylan Reference Manual.
Note that the CommonDylan library also has these extensions because it uses the Dylan library.
Ranges¶
The initialization arguments for <range>
must all be instances of
<machinenumber>
rather than <real>
.
Specific constructors¶
The following specific constructors are available for use with the class
<integer>
.

limited
Generic function¶ Defines a new type that represents a subset of the class
<integer>
. Signature
limited integerclass #key min max => limitedtype
 Parameters
integerclass – The singleton(<integer>).
min – The lower bound of the range. The default is
$minimuminteger
.max – The upper bound of the range. The default is
$maximuminteger
.
 Discussion
The integerclass argument is the class
<integer>
, and all other arguments are instances of<integer>
. The range of<integer>
is bounded by default.

range
Function¶ This function is used to specify ranges of numbers.
 Signature
range (#key from:, to:, above:, below:, by:, size:) => <range>
 Discussion
All of the supplied arguments must be instances of
<machinenumber>
.
Equality comparisons¶
The =
function compares two objects and returns #t
if the values of
the two objects are equal to each other, that is of the same magnitude.

=
Open Generic function¶ Tests its arguments to see if they are of the same magnitude.
 Signature
= object1 object2 => boolean

=(<complex>)
Sealed Method¶ Tests its arguments to see if they are of the same magnitude.
 Signature
= complex1 complex2 => boolean

=(<machinenumber>)
Method¶ Tests its arguments to see if they are of the same magnitude.
 Signature
= machinenumber1 machinenumber2 => boolean
Magnitude comparisons¶
The Dylan library provides the following interfaces for testing the magnitude of two numbers:

<
Open Generic function¶ Returns #t if its first argument is less than its second argument.
 Signature
< object1 object2 => boolean

<(<complex>)
Sealed Method¶ Returns #t if its first argument is less than its second argument.
 Signature
< complex1 complex2 => boolean

<(<machinenumber>)
Method¶ Returns #t if its first argument is less than its second argument.
 Signature
< machinenumber1 machinenumber2 => boolean
Properties of numbers¶
Various number properties can be tested using the following predicates in the Dylan library:

odd?
Open Generic function¶ Tests whether the argument supplied represents an odd value.
 Signature
odd? object => boolean

odd?(<complex>)
Sealed Method¶ Tests whether the argument supplied represents an odd value.
 Signature
odd? complex => boolean

odd?(<integer>)
Method¶ Tests whether the argument supplied represents an odd value.
 Signature
odd? integer => boolean

even?
Open Generic function¶ Tests whether the argument supplied represents an even value
 Signature
even? object => boolean

even?(<complex>)
Sealed Method¶ Tests whether the argument supplied represents an even value
 Signature
even? complex => boolean

even?(<integer>)
Method¶ Tests whether the argument supplied represents an even value
 Signature
even? integer => boolean

zero?
Open Generic function¶ Tests whether the argument supplied represents a zero value.
 Signature
zero? object => boolean

zero?(<complex>)
Sealed Method¶ Tests whether the argument supplied represents a zero value.
 Signature
zero? complex => boolean

zero?(<machinenumber>)
Method¶ Tests whether the argument supplied represents a zero value.
 Signature
zero? machinenumber => boolean

positive?
Open Generic function¶ Tests whether the argument supplied represents a positive value.

positive?(<complex>)
Sealed Method¶ Tests whether the argument supplied represents a positive value.
 Signature
positive? complex

positive?(<machinenumber>)
Method¶ Tests whether the argument supplied represents a positive value.
 Signature
positive? machinenumber => boolean

negative?
Open Generic function¶ Tests whether the argument supplied represents a negative value.
 Signature
negative? object => boolean

negative?(<complex>)
Sealed Method¶ Tests whether the argument supplied represents a negative value.
 Signature
negative? complex => boolean

negative?(<machinenumber>)
Method¶ Tests whether the argument supplied represents a negative value.
 Signature
negative? machinenumber => boolean

integral?
Open Generic function¶ Tests whether the argument supplied represents an integral value.
 Signature
integral? object => boolean

integral?(<complex>)
Sealed Method¶ Tests whether the argument supplied represents an integral value.
 Signature
integral? complex

integral?(<machinenumber>)
Method¶ Tests whether the argument supplied represents an integral value.
 Signature
integral? machinenumber => boolean
Arithmetic operations¶
The following arithmetic operations are available in the Dylan library:
+
Open generic function
+ object1 object2 => #rest object
+
Sealed domain
+ complex1 complex 2
+
G.f. method
+ integer1 integer 2 => integer
+
G.f. method
+ machinenumber1 machinenumber2 => machinenumber
Returns the sum of the two supplied arguments. The actual type of the value is determined by the contagion rules when applied to the arguments.

Open generic function
 object1 object2 => #rest object

Sealed domain
 complex1 complex2

G.f. method
 integer1 integer2 => integer

G.f. method
 machinenumber1 machinenumber2 => machinenumber
Returns the result of subtracting the second argument from the first. The actual type of the value is determined by the contagion rules when applied to the arguments.
*
Open generic function
* object1 object2 => #rest object
*
Sealed domain
* complex1 complex2
*
G.f. method
* integer1 integer 2 => integer
*
G.f. method
* machinenumber1 machinenumber2 => machinenumber
Returns the result of multiplying the two arguments. The actual type of the value is determined by the contagion rules when applied to the arguments.
/
Open generic function
/ object1 object2 => #rest object
/
Sealed domain
/ complex1 complex2
/
G.f. method
/ float1 float 2 => float
Returns the result of dividing the first argument by the second. The actual type of the value is determined by the contagion rules when applied to the arguments.
negative
Open generic function
negative object => #rest negativeobject
negative
Sealed domain
negative complex
negative
G.f. method
negative integer => negativeinteger
negative
G.f. method
negative float => negativefloat
Negates the supplied argument. The returned value is of the same float format as the supplied argument.
floor
Function
 floor machinenumber => integer machinenumber
floor integer => integer integer floor float => integer float
Truncates a number toward negative infinity. The integer part is returned as integer, the remainder is of the same float format as the argument.
ceiling
Function
 ceiling machinenumber => integer machinenumber
ceiling integer => integer integer ceiling float => integer float
Truncates a number toward positive infinity. The integer part is returned as integer, the remainder is of the same float format as the argument.
round
Function
 round machinenumber => integer machinenumber
round integer => integer integer round float => integer float
Rounds a number toward the nearest mathematical integer. The integer part is returned as integer, the remainder is of the same float format as the argument. If the argument is exactly between two integers, then the result integer will be a multiple of two.
truncate
Function
 truncate machinenumber => integer machinenumber
truncate integer => integer integer truncate float => integer float
Truncates a number toward zero. The integer part is returned as integer, the remainder is of the same float format as the argument.
floor/
Function
floor/ *machinenumber1* *machinenumber2* => *integer* *machinenumber*
floor/ *integer1* *integer2* => *integer* *integer*
floor/ *machinenumber1* *machinenumber2* => *integer* *machinenumber*
Divides the first argument into the second and truncates the result toward negative infinity. The integer part is returned as integer, the type of the remainder is determined by the contagion rules when applied to the arguments.
ceiling/
Function
ceiling/ *machinenumber1* *machinenumber2* => *integer* *machinenumber*
ceiling/ *integer1* *integer2* => *integer* *integer*
ceiling/ *machinenumber1* *machinenumber2* => *integer* *machinenumber*
Divides the first argument into the second and truncates the result toward positive infinity. The integer part is returned as integer, the type of the remainder is determined by the contagion rules when applied to the arguments.
round/
Function
round/ *machinenumber1* *machinenumber2* => *integer* *machinenumber*
round/ *integer1* *integer2* => *integer* *integer*
round/ *machinenumber1* *machinenumber2* => *integer* *machinenumber*
Divides the first argument into the second and rounds the result toward the nearest mathematical integer. The integer part is returned as integer, the type of the remainder is determined by the contagion rules when applied to the arguments.
truncate/
Function
truncate/ *machinenumber1* *machinenumber2* => *integer* *machinenumber*
truncate/ *integer1* *integer* 2 => *integer* *integer*
truncate/ *machinenumber1* *machinenumber2* => *integer* *machinenumber*
Divides the first argument into the second and truncates the result toward zero. The integer part is returned as integer, the type of the remainder is determined by the contagion rules when applied to the arguments.
modulo
Function
modulo *machinenumber1* *machinenumber2* => *machinenumber*
modulo *integer1* *integer2* => *integer*
modulo *machinenumber1* *machinenumber2* => *machinenumber*
Returns the second value of floor/ ( arg1 , arg2 ). The actual type of the second value is determined by the contagion rules when applied to the arguments.
remainder
Function
remainder *machinenumber1* *machinenumber2* => *machinenumber*
remainder *integer1* *integer2* => *integer*
remainder *machinenumber1* *machinenumber2* => *machinenumber*
Returns the second value of truncate/ ( arg1 , arg2 ).The actual type of the second value is determined by the contagion rules when applied to the arguments.
^
Open generic function
^ object1 object2 => #rest object
^
Sealed domain
^ complex1 complex 2
^
G.f. method
^ integer1 integer2 => integer
^
G.f. method
^ float1 integer2 => float
Returns the first argument raised to the power of the second argument. The value is of the same float format as the first argument. An error is signalled if both arguments are 0.
abs
Open generic function
abs object => #rest object
abs
Sealed domain
abs complex
abs
G.f. method
abs integer => integer
abs
G.f. method
abs float => float
Returns the absolute value of the argument. The value is of the same float format as the argument.
logior
Function
logior #rest integers => integer
Returns the bitwise inclusive OR of its integer arguments.
logxor
Function
logxor #rest integers => integer
Returns the bitwise exclusive OR of its integer arguments.
logand
Function
logand #rest integers => integer
Returns the bitwise AND of its integer arguments.
lognot
Function
lognot integer1 => integer2
Returns the bitwise NOT of its integer arguments.
logbit?
Function
logbit? index integer => boolean
Tests the value of a particular bit in its integer argument. The index
argument is an instance of <integer>
.
ash
Function
ash integer1 count => integer
Performs an arithmetic shift on its first argument.
lcm
Function
lcm integer1 integer2 => integer
Returns the least common multiple of its two arguments.
gcd
Function
gcd integer1 integer2 => integer
Returns the greatest common divisor of its two arguments.
Collections¶
The keys for sequences are always instances of <integer>
. This means
that certain kinds of collections cannot be sequences; very large (or
unbounded) sparse arrays are an example.
The Table Protocol¶
The following functions in the Dylan library are extended. Note that the
hash IDs for tables are always instances of <integer>
.
mergehashcodes
Function
 mergehashcodes id1 state1 id2 state2 #key ordered?
=> mergedid mergedstate
Returns a hash code created from the merging of two argument hash codes.
The id arguments are hash IDs, and the state arguments are hash
states (instances of <object>
). The ordered? argument is an
instance of <boolean>
. The returned merged values are instances of
<integer>
and <object>
, as determined by the name of each argument.
objecthash
Function
objecthash object => hashid hashstate
The hash function for the equivalence predicate ==. The return values
are of the same types as the return values of mergehashcodes
.
Iteration Constructs¶
for
Statement macro
The start, bound, and increment expressions in a numeric clause
must evaluate to instances of <machinenumber>
for this macro.
The genericarithmetic Library¶
The GenericArithmetic library exports the functions described in this section from an exported module called genericarithmetic.
The GenericArithmetic library provides a fully extensible version of all arithmetic operations. If an application only uses GenericArithmetic, these versions of the operators reduce themselves to be equivalent to those in the Dylan library. But when you use additional implementation libraries, the arithmetic operators are extended.
The BigIntegers library is one such implementation library. It provides
a 64bit implementation of <integer>
.
The standard integer implementation in the Dylan library is actually part of the following class hierarchy:
<abstractinteger>
<integer>
<biginteger>
<doubleinteger>
(The classes <biginteger>
and <doubleinteger>
are implementation
classes. You do not need to use them.)
The modules in the GenericArithmetic library export
<abstractinteger>
with the name <integer>
. They also export a full
set of arithmetic operators that use instances of <abstractinteger>
rather than instances of <integer>
(in the Dylan library naming
scheme). However, those operators just fall back to the Dylan library
operators until you include an implementation library, such as
BigIntegers, in your application.
When you use the BigIntegers library, the arithmetic operators exported
by GenericArithmetic are enhanced to extend their results to 64bit
integers. If a result is small enough to fit in a Dylan library
<integer>
, it will be fitted into one.
Note that the GenericArithmetic library uses the same naming conventions for arithmetic operators as used by the Dylan library. This means that some renaming is required in modules that require access to both the basic Dylan interfaces and the interfaces supplied by the GenericArithmetic library. As described earlier, the notation interface # module is used to denote different interfaces of the same name, where interface is the name of the interface, and module is the name of the module it is exported from.
See Using special arithmetic features for an example of how to use an implementation library with GenericArithmetic.
Ranges¶
The GenericArithmetic library defines the class <range>
, which is in
most respects functionally equivalent to <range>#Dylan, but uses
generic arithmetic operations in its implementation so that the
initialization arguments can be instances of <real>
, rather than
being restricted to <machinenumber>
.
Classes¶
The class <abstractinteger>
is imported and reexported under the
name <integer>#genericarithmetic.
Specific constructors¶
range
Function
range #key from to above below by size => range
This function is identical to the function range#Dylan, except that
all of the supplied arguments must be instances of <real>
.
Arithmetic operations¶
The following functions all apply function #Dylan to the arguments and return the results, where function is the appropriate function name. See Arithmetic operations for descriptions of each function as implemented in the Dylan library.
object1 object2 => #rest object
object1 object2 => #rest object
* object1 object2 => #rest object
/ object1 object2 => #rest object
negative object => #rest negativeobject
floor real1 => abstractinteger real
ceiling real1 => abstractinteger real
round real1 => abstractinteger real
truncate real1 => abstractinteger real
floor/ real1 real2 => abstractinteger real
ceiling/ real1 real2 => abstractinteger real
round/ real1 real2 => abstractinteger real
truncate/ real1 real2 => abstractinteger real
modulo real1 real2 => real
remainder real1 real2 => real
^ object1 object2 => #rest object
abs object1 => #rest object
logior #rest abstractinteger1 => abstractinteger
logxor #rest abstractinteger1 => abstractinteger
logand #rest abstractinteger1 => abstractinteger
lognot abstractinteger1 => abstractinteger
logbit? integer abstractinteger => boolean
ash abstractinteger1 integer => abstractinteger
lcm abstractinteger1 abstractinteger2 => abstractinteger
gcd abstractinteger1 abstractinteger2 => abstractinteger
Iteration constructs¶
While a programmer could make use of generic arithmetic in a for loop by using explicitstep clauses, this approach leads to a loss of clarity. The definition of the for macro is complex, so a version that uses generic arithmetic in numeric clauses is provided, rather than requiring programmers who want that feature to reconstruct it.
for
Statement macro
The start, bound, and increment expressions in a numeric clause
must evaluate to instances of <machinenumber>
for this macro.
Otherwise, this macro is similar to for#Dylan.
Exported Modules from the genericarithmetic Library¶
The GenericArithmetic library exports several modules that are provided for the convenience of programmers who wish to create additional modules based on the dylan module plus various combinations of the arithmetic models.
The dylanexcludingarithmetic Module¶
The DylanExcludingArithmetic module imports and reexports all of the interfaces exported by the dylan module from the Dylan library, except for the following excluded interfaces:
The dylanarithmetic Module¶
The DylanArithmetic module imports and reexports all of the interfaces exported by the dylan module from the Dylan library which are excluded by the dylanexcludingarithmetic module.
The genericarithmeticdylan Module¶
The GenericArithmeticDylan module imports and reexports all of the interfaces exported by the dylanexcludingarithmetic module and the genericarithmetic module.
The dylanexcludingarithmetic, dylanarithmetic, and genericarithmetic modules provide convenient building blocks for programmers to build the particular set of global name bindings they wish to work with. The purpose of the genericarithmeticdylan module is to provide a standard environment in which generic arithmetic is the norm, for those programmers who might want that.
Using Special Arithmetic Features¶
As noted in The GenericArithmetic library, the GenericArithmetic library provides an extensible protocol for adding specialized arithmetic functionality to your applications. By using the GenericArithmetic library alongside a special implementation library, you can make the standard arithmetic operations support number types such as big (64bit) integers, or complex numbers.
This section provides an example of extending the basic Dylan arithmetic features using the GenericArithmetic library and the BigIntegers implementation library.
To use special arithmetic features, a library’s define library
declaration must use at least the following libraries:
commondylan
genericarithmetic
specialarithmeticimplementationlibrary
So for BigIntegers you would write:
define library foo
use commondylan;
use genericarithmetic;
use bigintegers;
...
end library foo;
Next you have to declare a module. There are three ways of using biginteger arithmetic that we can arrange with a suitable module declaration:
Replace all integer arithmetic with the biginteger arithmetic
Use both, with normal arithmetic remaining the default
Use both, with the biginteger arithmetic becoming the default
To get one of the three different effects described above, you need to
arrange the define module
declaration accordingly. To replace all
integer arithmetic with biginteger arithmetic, include the following in
your define module
declaration:
use genericarithmeticcommondylan;
(Note that the module definition should not use the BigIntegers module. The BigIntegers library is used as a sideeffects library only, that is, it is referenced in the library definition so that it will be loaded. Its definitions extend the GenericArithmetic library.)
If you replace all integer arithmetic with biginteger arithmetic in this way, there will be performance hits. For instance, loop indices will have to be checked at runtime to see whether a normal or big integer representation is being used, and a choice must be made about the representation for an incremented value.
You can take a different approach that reduces the cost of biginteger
arithmetic. Under this approach you leave normal integer arithmetic
unchanged, and get access to biginteger arithmetic when you need it. To
do this, use the same libraries but instead of using the
commondylangenericarithmetic
module, include the following in your
define module
declaration:
use commondylan;
use genericarithmetic, prefix: "ga/"; // use any prefix you like
This imports the biginteger arithmetic binding names, but gives them a
prefix ga/
, using the standard renaming mechanism available in module
declarations. Thus you gain access to big arithmetic using renamed
classes and operations like:
ga/<integer>
ga/+
ga/
ga/*
...
The operations take either instances of <integer>
or ga/<integer>
(a
subclass of <integer>
) and return instances of ga/<integer>
.
Note that having imported the biginteger operations under new names, you have to use prefix rather than infix syntax when calling them. For example:
ga/+ (5, 4);
not:
5 ga/+ 4;
The existing functions like +
and 
will only accept <integer>
instances and ga/<integer>
instances small enough to be represented as
<integer>
instances.
Under this renaming scheme, reduced performance will be confined to the
ga/
operations. Other operations, such as loop index increments and
decrements, will retain their efficiency.
Finally, you can make biginteger arithmetic the default but keep normal
arithmetic around for when you need it. Your define module
declaration should contain:
use genericarithmeticcommondylan;
use dylanarithmetic, prefix: "dylan/"; //use any prefix you like
The bigintegers Library¶
The BigIntegers library exports a module called bigintegers
, which
imports and reexports all of the interfaces exported by the
genericarithmetic
module of the GenericArithmetic library.
The BigIntegers library modifies the behavior of functions provided by the Dylan library as described in this section.
Specific Constructors¶
The BigIntegers library extends the functionality of specific constructors in the Dylan library as follows:
limited
G.f. method
limited abstractintegerclass #key min max => limitedtype
Returns a limited integer type, which is a subtype of
<abstractinteger>
, whose instances are integers greater than or
equal to min (if specified) and less than or equal to max (if
specified). If no keyword arguments are specified, the result type is
equivalent to <abstractinteger>
. The argument
abstractintegerclass is the class <abstractinteger>
.
If both min and max are supplied, and both are instances of
<integer>
, then the result type is equivalent to calling limited on
<integer>
with those same bounds.
The Limited Integer Type Protocol is extended to account for limited
<abstractinteger>
types.
Instances and subtypes in the BigIntegers library
:: todo Fix header style here—
This is true if and only if …
… all these clauses are true
 instance?
(x, limited(<abstractinteger>, min: y, max: z))
 instance?(x, <abstractinteger>)
(y <= x) (x <= z)
 instance?
(x, limited(<abstractinteger>, min: y))
 instance?(x, <abstractinteger>)
(y <= x)
 instance?
(x, limited(<abstractinteger>, max: z))
 instance?(x, <abstractinteger>)
(x <= z)
 subtype?
(limited(<abstractinteger>, min: w, max: x), limited(<abstractinteger>, min: y, max: z))
 (w >= y)
(x <= z)
 subtype?
(limited(<abstractinteger>, min: w …), limited(<abstractinteger>, min: y))
(w >= y)
 subtype?
(limited(<abstractinteger>, max: x …), limited(<abstractinteger>, max: z))
(x <= z)
Typeequivalence in the BigIntegers library :: todo Fix header style here—
This is type equivalent to …
… this, if and only if …
… this is true
 limited
(<abstractinteger>, min: y, max: z)
 limited
(<integer>, min: y, max: z)
y and z are both instances of <integer>
.
 limited
(<abstractinteger>, min: y, max: $maximuminteger)
 limited
(<integer>, min: y)
y is an instance of <integer>
.
 limited
(<abstractinteger>, min: $minimuminteger, max: z)
 limited
(<integer>, max: z)
z is an instance of <integer>
.
Type disjointness is modified as follows to account for limited
<abstractinteger>
types.
A limited integer type is disjoint from a class if their base types are
disjoint or the class is <integer>
and the range of the limited
integer type is disjoint from the range of <integer>
(that is, from
$minimuminteger to $maximuminteger).
Equality comparisons¶
The behavior of equality comparisons in the Dylan library is modified by the BigIntegers library as follows:
= *abstractinteger1* *abstractinteger2* => *boolean*
= *abstractinteger* *float* => *boolean*
= *float* *abstractinteger* => *boolean*
Magnitude comparisons¶
The behavior of magnitude comparisons in the Dylan library is modified by the BigIntegers library as follows:
< *abstractinteger1* *abstractinteger2* => *boolean
< *abstractinteger* *float* => *boolean*
< *float* *abstractinteger* => *boolean*
Properties of Numbers¶
The behavior of number property tests in the Dylan library is modified by the BigIntegers library as follows:
odd? *abstractinteger* => *boolean*
even? *abstractinteger* => *boolean*
zero? *abstractinteger* => *boolean*
positive? *abstractinteger* => *boolean*
negative? *abstractinteger* => *boolean*
integral? *abstractinteger* => *boolean*
Arithmetic Operations¶
The BigIntegers library modifies the behavior of the functions provided by the GenericArithmetic library as described below.
The actual type of the return value for all the following interfaces is determined by the contagion rules when applied to the arguments.
+ *abstractinteger1* *abstractinteger2* => *abstractinteger*
+ *abstractinteger* *float1* => *float*
+ *float1* *abstractinteger* => *float*
 *abstractinteger1* *abstractinteger2* => *abstractinteger*
 *abstractinteger* *float1* => *float*
 *float1* *abstractinteger* => *float*
\* *abstractinteger1* *abstractinteger2* => *abstractinteger*
\* *abstractinteger* *float1* => *float*
\* *float1* *abstractinteger* => *float*
The return value of the following interface is of the same float format as the argument:
negative *abstractinteger* => *negativeabstractinteger*
The second return value of all the following interfaces is of the same float format as the argument:
floor *abstractinteger* => *abstractinteger1* *abstractinteger2*
floor *float1* => *abstractinteger* *float*
ceiling *abstractinteger* => *abstractinteger1* *abstractinteger2*
ceiling *float1* => *abstractinteger* *float*
round *abstractinteger* => *abstractinteger1* *abstractinteger2*
round *float1* => *abstractinteger* *float*
truncate *abstractinteger* => *abstractinteger1* *abstractinteger2*
truncate *float1* => *abstractinteger* *float*
The second return value of all the following interfaces is of the same float format as the first argument:
floor/ *abstractinteger1* *abstractinteger2* => *abstractinteger3* *abstractinteger4*
floor/ *float1* *abstractinteger1* => *abstractinteger2* *float2*
ceiling/ *abstractinteger1* *abstractinteger2* => *abstractinteger3* *abstractinteger4*
ceiling/ *float1* *abstractinteger1* => *abstractinteger2* *float2*
round/ *abstractinteger1* *abstractinteger2* => *abstractinteger3* *abstractinteger4*
round/ *float1* *abstractinteger1* => *abstractinteger2* *float2*
truncate/ *abstractinteger1* *abstractinteger2* => *abstractinteger3* *abstractinteger4
truncate/ *float1* *abstractinteger1* => *abstractinteger2* *float2*
The second return value of the following interfaces is of the same float format as the second argument:
floor/ *abstractinteger1* *float1* => *abstractinteger2* *float2*
ceiling/ *abstractinteger1* *float1* => *abstractinteger2* *float2*
round/ *abstractinteger1* *float1* => *abstractinteger2* *float2*
truncate/ *abstractinteger1* *float1* => *abstractinteger2* *float2*
The return value of the following interfaces is of the same float format as the first argument:
modulo *float1* *abstractinteger* => *float*
remainder *float1* *abstractinteger* => *float*
The return value of the following interfaces is of the same float format as the second argument:
modulo *abstractinteger1* *abstractinteger2* => *abstractinteger*
modulo *abstractinteger* *float1* => *float*
remainder *abstractinteger1* *abstractinteger2* => *abstractinteger*
remainder *abstractinteger* *float1* => *float*
The behavior of the following miscellaneous interfaces is also modified by the BigIntegers library:
^ *abstractinteger1* *integer* => *abstractinteger
abs *abstractinteger1* => *abstractinteger*
logior #rest *abstractinteger1* => *abstractinteger*
logxor #rest *abstractinteger1* => *abstractinteger*
logand #rest *abstractinteger1* => *abstractinteger*
lognot *abstractinteger1* => *abstractinteger*
logbit? *integer* *abstractinteger* => *boolean*
ash *abstractinteger1* *integer* => *abstractinteger*
lcm *abstractinteger1* *abstractinteger2* => *abstractinteger*
gcd *abstractinteger1* *abstractinteger2* => *abstractinteger*