Next: 3.6 Collections
Up: 3 The Slate World
Previous: 3.4 Control-flow
  Contents
Subsections
- Magnitude
- the abstract protocol for linearly-comparable
objects, following <, >, <=, >=,
and =.
- Number
- the abstract type of dimensionless quantities.
- Integer
- integral quantities, generally.
- SmallInteger
- machine-word-limited integer values (minus
2 bits for type tags). Their normal protocol will not produce errors
inconsistent with mathematic behavior of Integers, however.
(Instead of overflows, integer objects are returned.)
- BigInteger
- larger Integers, implemented as WordArrays.
- Fraction
- An exact representation of a quotient, or rational
number.
- Float
- A low-level floating-point numeric representation,
being inexact.
- Complex
- A complex number, similar to a pair of real numbers.
All of the normal arithmetic operations (i.e. +, -,
*, /) are supported primitively between elements
of the same type. Type coercion has to be done entirely in code; no
implicit coercions are performed by the virtual machine. However,
the standard library includes methods which perform this coercion.
The interpreter also transparently provides unlimited-size integers,
although the bootstrapped system may not do so implicitly.
The following are the rest of the primitive operations, given with
an indication of their "signatures":
- Float raisedTo: Float
- is simple floating-point exponentiation.
- Integer as: Float
- extends an integer into a float.
- Float as: Integer
- truncates a float.
- Integer bitOr: Integer
- performs bitwise logical OR.
- Integer bitXor: Integer
- performs bitwise logical XOR.
- Integer bitAnd: Integer
- performs bitwise logical AND.
- Integer bitShift: Integer
- performs bitwise logical right-shift
(left-shift if negative).
- Integer bitNot
- performs bitwise logical NOT.
- Integer >> Integer
- performs logical
right-shift.
- Integer << Integer
- performs logical
left-shift.
- Integer quo: Integer
- returns a quotient (integer division).
Many more useful methods are defined, such as mod:, reciprocal,
min:, max:, between:and:, lcm:,
and gcd:. Slate also works with Fractions when dividing
Integers, keeping them lazily reduced.
- zero
- The zero element for the type of number.
- isZero
- Whether the number is the zero element for its type.
- isPositive/isNegative
- Whether its positive or
negative.
- abs
- The absolute value of the number.
- sign
- The sign of the number.
- negated
- Returns -x for x.
- gcd:
- Greatest common divisor.
- lcm:
- Least common multiple.
- factorial
- Factorial.
- mod:/rem:/quo:
- Modulo division, remainder,
and quotient.
- reciprocal
- Constructs a new fraction reciprocal.
- min:
- The lesser of the arguments. The least in cases of
min:min:.
- max:
- The greater of the arguments. The greatest in cases
of max:max:.
- a between: b and: c
- Whether a is between b
and c.
- truncated/fractionPart
- Returns the greatest integer
less than the number, and the corresponding difference as a fraction
(or a float for Float).
- reduced
- Only defined on Fraction, this is the
lazily-applied reducer; it will be invoked automatically for arithmetic
operations as necessary, but is useful when only the reduced form
is needed.
- PositiveInfinity
- is greater than any other Magnitude.
- NegativeInfinity
- is lesser than any other Magnitude.
- LargeUnbounded
- A Magnitude designed to represent
non-infinite, but non-bounded (``as large as you like'') quantities.
- PositiveEpsilon
- is as small as you like, but positive and
greater than zero.
- NegativeEpsilon
- is as small as you like, but negative and
lesser than zero.
There is an entire system for handling dimensioned units and their
various combinations and mathematical operations. There is included
support for SI units, and common English units; furthermore, any object
may conceivably be used as a base unit. See the 'src/dimensioned.slate'
file for an overview.
Next: 3.6 Collections
Up: 3 The Slate World
Previous: 3.4 Control-flow
  Contents
The Slate Project
2004-01-04