Structures

The following structures are available globally.

  • AbstractState: RatNum represents an immutable rational number. It includes all of the elements in the set of rationals, as well as the special NaN (not-a-number) element that results from division by zero.

    The NaN element is special in many ways. Any arithmetic operation (such as addition) involving NaN will return NaN. With respect to comparison operations, such as less-than, NaN is considered equal to itself, and larger than all other rationals.

    Examples of RatNums include -1/13, 53/7, 4, NaN, and 0.

    See more

    Declaration

    Swift

    public struct RatNum : Comparable, CustomStringConvertible
  • RatTerm is an immutable representation of a term in a single-variable polynomial expression. The term has the form C*x^E where C is a rational number and E is an integer.

    AbstractState: A RatTerm, t, can be notated by the pair (C . E), where C is the coefficient of t, and E is the exponent of t.

    The zero RatTerm, (0 . 0), is the only RatTerm that may have a zero coefficient. For example, (0 . 7) is an invalid RatTerm and an attempt to construct such a RatTerm (through the constructor or arithmetic operations on existing RatTerms) will return the semantically equivalent RatTerm (0 . 0). For example, (1 . 7) + (-1 . 7) = (0 . 0).

    (0 . 0), (1 . 0), (1 . 1), (1 . 3), (¾ . 17), (7/2 . -1), and (NaN . 74) are all valid RatTerms, corresponding to the polynomial terms 0, 1, x, x^3, ¾*x^17, 7/2*x^-1 and NaN*x^74, respectively.

    See more

    Declaration

    Swift

    public struct RatTerm : Equatable, CustomStringConvertible