Number system

The number module defines interfaces that unifies different kinds of numbers. Currently there is one root interface Number, from which are derived interfaces Real, Complex, Integer and Float.

interface Number

Interface Number is intended to be the root of the number system. It contains conversion from integers and to floating-point numbers.

Methods ^^^^^^^

======================== ================================= Method Description ======================== ================================= static fromInt(n) Convert from Int64 static getSize() Number of bytes used by this type static getType() Name of the type operator +(right) Addition operator -(right) Subtraction operator *(right) Multiplication operator ==(right) Test for equality operator !=(right) Test for inequality ======================== =================================

interface Real <: Number

Interface Real contains all real numbers. It contains additionally comparison operators, taking absolute value, and conversion to Float64.

======================== ================================= Method Description ======================== ================================= operator <(right) Less-than operator <=(right) Less-than or equal operator >(right) Greater-than operator >=(right) Greater-than or equal abs(n) Absolute value toFloat64() Conversion to Float64 ======================== =================================

interface Integer <: Real

Interface Integer contains all types that correspond to integers.

interface UnsignedInteger <: Integer

Interface UnsignedInteger contains all types that correspond to unsigned integers.

Types implementing this interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  • UInt8 <: UnsignedInteger
  • UInt16 <: UnsignedInteger
  • UInt32 <: UnsignedInteger
  • UInt64 <: UnsignedInteger

interface SignedInteger <: Integer

Types implementing this interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  • Int8 <: SignedInteger
  • Int16 <: SignedInteger
  • Int32 <: SignedInteger
  • Int64 <: SignedInteger

interface Float <: Number

Interface Float contains all types that correspond to Floating-point (inexact) real numbers.

Methods ^^^^^^^

================================ ================================= Method Description ================================ ================================= static fromFloat(x) Conversion from Float64 static sqrt(x) Square root static power(base, exponent) Power static log(x) Natural logarithm static log2(x) Base-2 logarithm static log10(x) Base-10 logarithm static exp(x) Exponential static eps() Epsilon value operator /(right) Division ================================ =================================

Types implementing this interface ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  • Float32 <: Float
  • Float64 <: Float

Additional methods

The numbers package defines generic functions that can be used on all types implementing a particular interface.

========================== ================================= Method Description ========================== ================================= abs(x) Absolute value (Real) sqrt(x) Square root (Float) power(base, exponent) Power (Float) log(x) Natural logarithm (Float) log2(x) Base-2 logarithm (Float) log10(x) Base-10 logarithm (Float) exp(x) Exponential approxEqual(a, b[, atol]) Approximate equality ========================== =================================

interface Complex <: Number

Interface Complex contains all types that correspond to complex numbers.

Methods ^^^^^^^

========================== ================================= Method Description ========================== ================================= conjugate() Conjugate approxEqual(right[, atol]) Approximate equality ========================== =================================

class Complex64 <: Complex

Member variables ^^^^^^^^^^^^^^^^

========================== ================================= Member variables Description ========================== ================================= real: Float64 Real part imag: Float64 Imaginary part ========================== =================================

Methods ^^^^^^^

========================== ================================= Member variables Description ========================== ================================= normsq() Squared-norm norm() Norm ========================== =================================

class Complex32 <: Complex

Member variables ^^^^^^^^^^^^^^^^

========================== ================================= Member variables Description ========================== ================================= real: Float32 Real part imag: Float32 Imaginary part ========================== =================================

Methods ^^^^^^^

========================== ================================= Member variables Description ========================== ================================= normsq() Squared-norm norm() Norm ========================== =================================