ExactNumber

com.phasmidsoftware.number.core.numerical.ExactNumber
See theExactNumber companion object
case class ExactNumber(nominalValue: Value, factor: Factor) extends GeneralNumber

This class is designed to model an exact Numeral. See GeneralNumber for more details on the actual representation.

TODO implement scientific notation by having factors such os 10∧3, 10∧6, etc. (alternatively, add a separate parameter)

Value parameters

factor

the scale factor of the Number: valid scales are: PureNumber, Radian, and NatLog.

nominalValue

the nominalValue of the Number, expressed as a nested Either type.

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait Number
trait Numerical
trait NumberLike
trait Ordered[Number]
trait Comparable[Number]
trait Fuzz[Double]
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

def compare(other: Number): Int

Method to compare this Number with another.

Method to compare this Number with another.

Value parameters

other

the other Number.

Attributes

Returns

-1, 0, or 1 according to the relative magnitudes.

def doAdd(n: Number): Number

Add this Number to n.

Add this Number to n.

NOTE: there is currently a significant difference between GeneralNumber.plus and FuzzyNumber.plus

Value parameters

n

another Number.

Attributes

Returns

the sum of this and n.

Multiply this Number by n.

Multiply this Number by n.

NOTE: there is currently a significant difference between GeneralNumber.plus and FuzzyNumber.plus

Value parameters

n

another Number.

Attributes

Returns

the product of this and n.

def doPower(p: Number): Number

Raise this Number to the power p.

Raise this Number to the power p.

Value parameters

p

a Number.

Attributes

Returns

this Number raised to the power of p.

override def equals(obj: Any): Boolean

Compares this instance with another object to determine equality. Equality is determined based on specific conditions for the ExactNumber type. NOTE that there may be a few rare situations where we return false for two "equal" numbers. However, generally speaking, numbers should be normalized before equality testing.

Compares this instance with another object to determine equality. Equality is determined based on specific conditions for the ExactNumber type. NOTE that there may be a few rare situations where we return false for two "equal" numbers. However, generally speaking, numbers should be normalized before equality testing.

Value parameters

obj

the object to be compared with this instance

Attributes

Returns

true if the specified object is equal to this instance; false otherwise

Definition Classes
Equals -> GeneralNumber -> Any
override def hashCode(): Int

Generates a hash code for this ExactNumber object. The hash code is computed based on the nominalValue and factor fields and is therefore consistent with equals.

Generates a hash code for this ExactNumber object. The hash code is computed based on the nominalValue and factor fields and is therefore consistent with equals.

Attributes

Returns

an integer hash code value for this object.

Definition Classes
GeneralNumber -> Any
def isProbablyZero(confidence: Double = ...): Boolean

Method to determine if this Number is probably zero. It is used particularly when comparing two Numbers to see if they are the same.

Method to determine if this Number is probably zero. It is used particularly when comparing two Numbers to see if they are the same.

Value parameters

confidence

the confidence desired. Ignored.

Attributes

Returns

true if this Number is actually zero.

def isSame(x: Numerical, confidence: Double): Boolean

Determines if this ExactNumber is equivalent to another Numerical object (x).

Determines if this ExactNumber is equivalent to another Numerical object (x).

Value parameters

x

the other Numerical object to compare against. It could be of type Real, FuzzyNumber, ExactNumber, or Complex.

Attributes

Returns

true if the two Numerical objects are considered the same, otherwise false.

def make(v: Value, f: Factor): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Both the value and the factor will be changed.

Make a copy of this Number, given the same degree of fuzziness as the original. Both the value and the factor will be changed.

CONSIDER should be invoke simplify from other make methods?

Value parameters

f

the factor.

v

the value.

Attributes

Returns

an ExactNumber.

def make(fo: Option[Fuzziness[Double]]): Number

We cannot add fuzziness to an Exact number, so we return the equivalent FuzzyNumber.

We cannot add fuzziness to an Exact number, so we return the equivalent FuzzyNumber.

Value parameters

fo

the (optional) fuzziness.

Attributes

Returns

a Number.

def make(v: Double, f: Factor, fo: Option[Fuzziness[Double]]): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Only the nominalValue and factor will change. This method should be followed by a call to specialize.

Make a copy of this Number, given the same degree of fuzziness as the original. Only the nominalValue and factor will change. This method should be followed by a call to specialize.

Value parameters

f

Factor.

fo

optional fuzz.

v

the nominalValue (a Double).

Attributes

Returns

either a Number.

def probabilityOfZero: Option[Double]

Computes the probability that this number is exactly zero. The calculation depends on the specific implementation details or state of the instance.

Computes the probability that this number is exactly zero. The calculation depends on the specific implementation details or state of the instance.

Attributes

Returns

an Option containing a Double representing the probability that the number is zero, or None if the probability cannot be determined.

def signum(confidence: Double): Int

Method to determine the sense of this number: negative, zero, or positive. If this FuzzyNumber cannot be distinguished from zero with p confidence, then the result will be zero.

Method to determine the sense of this number: negative, zero, or positive. If this FuzzyNumber cannot be distinguished from zero with p confidence, then the result will be zero.

Value parameters

confidence

the confidence desired (ignored).

Attributes

Returns

an Int which is negative, zero, or positive, according to the magnitude of this.

def thresholdConfidence: Option[Double]

Retrieves the threshold confidence value associated with this ExactNumber. The threshold confidence represents an optional value that might be used to determine the confidence level for certain computations or evaluations involving this number.

Retrieves the threshold confidence value associated with this ExactNumber. The threshold confidence represents an optional value that might be used to determine the confidence level for certain computations or evaluations involving this number.

Attributes

Returns

an Option containing a Double that represents the threshold confidence, or None if the threshold confidence is not set or applicable.

Inherited methods

def <(that: Number): Boolean

Returns true if this is less than that

Returns true if this is less than that

Value parameters

that

the instance to compare against

Attributes

Inherited from:
Ordered
def <=(that: Number): Boolean

Returns true if this is less than or equal to that.

Returns true if this is less than or equal to that.

Attributes

Inherited from:
Ordered
def >(that: Number): Boolean

Returns true if this is greater than that.

Returns true if this is greater than that.

Value parameters

that

the instance to compare against

Attributes

Inherited from:
Ordered
def >=(that: Number): Boolean

Returns true if this is greater than or equal to that.

Returns true if this is greater than or equal to that.

Attributes

Inherited from:
Ordered
def add(x: Field): Field

Add x to this Number and return the result.

Add x to this Number and return the result.

Value parameters

x

the addend.

Attributes

Returns

the sum.

Inherited from:
Number
def addFuzz(f: Fuzziness[Double]): Number

Make a copy of this FuzzyNumber but with additional fuzz given by f.

Make a copy of this FuzzyNumber but with additional fuzz given by f.

Value parameters

f

the additional fuzz.

Attributes

Returns

this but with fuzziness which is the convolution of fuzz and f.

Inherited from:
GeneralNumber

Method to align the factors of this and x such that the resulting Numbers (in the tuple) each have the same factor.

Method to align the factors of this and x such that the resulting Numbers (in the tuple) each have the same factor.

Value parameters

x

the Number to be aligned with this.

Attributes

Returns

a tuple of two Numbers with the same factor.

Inherited from:
GeneralNumber

Method to align the types of this and x such that the resulting Numbers (in the tuple) each have the same structure.

Method to align the types of this and x such that the resulting Numbers (in the tuple) each have the same structure.

CONSIDER renaming this alignValueTypes

Value parameters

q

the Number to be aligned with this.

Attributes

Returns

a tuple of two Numbers, the first of which will be the more general type: (Invalid vs. Double, Double vs. Rational, Rational vs. Int).

Inherited from:
GeneralNumber
def applyFunc(f: Double => Double, dfByDx: Double => Double): Try[Number]

Method to apply a function to this Number.

Method to apply a function to this Number.

Value parameters

dfByDx

the first derivative of f.

f

a function Double=>Double.

Attributes

Returns

a Try[Number] which is the result of applying f to this Number.

Inherited from:
GeneralNumber
def asComparedWith(other: Number): Option[Fuzziness[Double]]

Method to derive a fuzziness that covers the discrepancy between this and other.

Method to derive a fuzziness that covers the discrepancy between this and other.

Value parameters

other

another Number: the ideal or target value.

Attributes

Returns

an optional relative Fuzziness.

Inherited from:
GeneralNumber
def asJavaNumber: Option[Number]

Converts this NumberLike object into an optional java.lang.Number provided that the conversion can be performed without loss of precision.

Converts this NumberLike object into an optional java.lang.Number provided that the conversion can be performed without loss of precision.

The method determines whether the current NumberLike object can be represented as a java.lang.Number by leveraging the asNumber method and further evaluating certain conditions:

  • If the NumberLike object is an ExactNumber and its factor is PureNumber, the result is converted using Value.asJavaNumber.
  • If the NumberLike object is a FuzzyNumber with a wiggle value below a specified tolerance, the result is also converted using Value.asJavaNumber.
  • In all other cases, None is returned.

Attributes

Returns

an optional java.lang.Number representation of this object. The result is Some(java.lang.Number) if the conversion is successful under the stated conditions; otherwise, None.

Inherited from:
NumberLike
def asNumber: Option[Number]

Attributes

Returns

Some(this).

Inherited from:
Number
def asReal: Option[Real]

Method to return this ExactNumber as a Real.

Method to return this ExactNumber as a Real.

Attributes

Returns

Some(Real(this)).

Inherited from:
GeneralNumber
def atan(y: Number): Number

Calculate the angle whose opposite length is y and whose adjacent length is this.

Calculate the angle whose opposite length is y and whose adjacent length is this.

Value parameters

y

the opposite length

Attributes

Returns

the angle defined by x = this, y = y

Inherited from:
GeneralNumber
def compare(that: Field): Int

Method to compare this Number with that Field. Required by implementing Ordered[Field].

Method to compare this Number with that Field. Required by implementing Ordered[Field].

Value parameters

that

(a Field).

Attributes

Returns

the comparison.

Inherited from:
GeneralNumber
def compareTo(that: Number): Int

Result of comparing this with operand that.

Result of comparing this with operand that.

Value parameters

that

the instance to compare against

Attributes

Inherited from:
Ordered
def composeDyadic(other: Number, f: Factor)(op: DyadicOperation): Option[Number]

Evaluate a dyadic operator on this and other, using either plus, times, ... according to the value of op. NOTE: this and other must have been aligned by type so that they have the same structure.

Evaluate a dyadic operator on this and other, using either plus, times, ... according to the value of op. NOTE: this and other must have been aligned by type so that they have the same structure.

Value parameters

f

the factor to apply to the result.

op

the appropriate DyadicOperation.

other

the other operand, a Number.

Attributes

Returns

a new Number which is result of applying the appropriate function to the operands this and other.

Inherited from:
GeneralNumber
def divide(x: Field): Field

Divide this Number by x and return the result.

Divide this Number by x and return the result.

Value parameters

x

the divisor.

Attributes

Returns

the quotient.

Inherited from:
Number

Divide this Number by n.

Divide this Number by n.

Value parameters

n

another Number.

Attributes

Returns

this quotient of this and n, i.e. this/n.

Inherited from:
GeneralNumber

Perform an exact scalar multiplication of this Number by the scale factor r.

Perform an exact scalar multiplication of this Number by the scale factor r.

NOTE that numbers with Logarithmic factors cannot be scaled exactly in this way.

Value parameters

r

a Rational.

Attributes

Returns

a new Number which is this Number scaled by z.

Inherited from:
Number
def doMultiple(x: Int): Number

Perform an exact scalar multiplication of this Number by the scale factor x. Implemented by doMultiple(Rational) where you should consult NOTE

Perform an exact scalar multiplication of this Number by the scale factor x. Implemented by doMultiple(Rational) where you should consult NOTE

Value parameters

x

an Int.

Attributes

Returns

a new Number which is this Number scaled by z.

Inherited from:
Number

Subtract n from this Number

Subtract n from this Number

Value parameters

n

another Number.

Attributes

Returns

the difference of this and n.

Inherited from:
Number
def fuzzyCompare(other: Number, confidence: Double): Int

Perform a fuzzy comparison where we only require p confidence to know that this and other are effectively the same.

Perform a fuzzy comparison where we only require p confidence to know that this and other are effectively the same.

NOTE: This method is used, although it doesn't appear so.

Value parameters

confidence

the confidence expressed as a fraction of 1 (oneSigma would be a typical value).

other

the Number to be compared with.

Attributes

Returns

-1, 0, 1 as usual.

Inherited from:
GeneralNumber
def log(b: Number): Number

Calculates the logarithm of the current number to the given base.

Calculates the logarithm of the current number to the given base.

Value parameters

b

the base of the logarithm

Attributes

Returns

the logarithm of the current number to the given base, or NaN if the calculation fails

Inherited from:
GeneralNumber
def make(x: Double, f: Factor): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Only the value and factor will change. This method should be followed by a call to specialize.

Make a copy of this Number, given the same degree of fuzziness as the original. Only the value and factor will change. This method should be followed by a call to specialize.

TESTME

Value parameters

f

Factor.

x

the value (a Double).

Attributes

Returns

a Number.

Inherited from:
GeneralNumber
def make(r: Rational): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Only the value will change. This method should be followed by a call to specialize.

Make a copy of this Number, given the same degree of fuzziness as the original. Only the value will change. This method should be followed by a call to specialize.

Value parameters

r

the value.

Attributes

Returns

a Number.

Inherited from:
GeneralNumber
def make(r: Rational, f: Factor): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Only the value and the factor will change. This method should be followed by a call to specialize.

Make a copy of this Number, given the same degree of fuzziness as the original. Only the value and the factor will change. This method should be followed by a call to specialize.

NOTE that this method is primarily used by doComposeDyadic

Value parameters

f

Factor.

r

a Rational.

Attributes

Returns

a Number.

Inherited from:
GeneralNumber
def make(v: Int): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Only the value will change. This method should be followed by a call to specialize.

Make a copy of this Number, given the same degree of fuzziness as the original. Only the value will change. This method should be followed by a call to specialize.

Value parameters

v

the value.

Attributes

Returns

a Number.

Inherited from:
GeneralNumber
def make(v: Int, f: Factor): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Only the nominalValue will change. This method should be followed by a call to specialize.

Make a copy of this Number, given the same degree of fuzziness as the original. Only the nominalValue will change. This method should be followed by a call to specialize.

Value parameters

f

Factor.

v

the nominalValue.

Attributes

Returns

a Number.

Inherited from:
GeneralNumber
def make(v: Value): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Only the nominalValue will change. This method should be followed by a call to specialize.

Make a copy of this Number, given the same degree of fuzziness as the original. Only the nominalValue will change. This method should be followed by a call to specialize.

Value parameters

v

the nominalValue.

Attributes

Returns

a Number.

Inherited from:
GeneralNumber
def make(f: Factor): Number

Make a copy of this Number, given the same degree of fuzziness as the original. Only the factor will change. This method does not need to be followed by a call to specialize.

Make a copy of this Number, given the same degree of fuzziness as the original. Only the factor will change. This method does not need to be followed by a call to specialize.

Value parameters

f

the factor.

Attributes

Returns

a Number.

Inherited from:
GeneralNumber
def maybeFactor: Option[Factor]

Retrieves an optional Factor instance.

Retrieves an optional Factor instance.

Attributes

Returns

Some(factor).

Inherited from:
Number
def maybeNominalDouble: Option[Double]

An optional Double that corresponds to the nominalValue of this Number (but ignoring the factor). If

An optional Double that corresponds to the nominalValue of this Number (but ignoring the factor). If

Attributes

Returns

Some(x) if nominalValue can be converted properly to a Double, otherwise None.

Inherited from:
GeneralNumber

An optional Rational that corresponds to the nominalValue of this Number (but ignoring the factor). A Double nominalValue is not converted to a Rational since, if it could be done exactly, it already would have been. CONSIDER using query

An optional Rational that corresponds to the nominalValue of this Number (but ignoring the factor). A Double nominalValue is not converted to a Rational since, if it could be done exactly, it already would have been. CONSIDER using query

Attributes

Inherited from:
GeneralNumber
def memberOf(set: NumberSet): Boolean

Method to determine if this NumberLike object is a member of the given set.

Method to determine if this NumberLike object is a member of the given set.

Value parameters

set

the candidate NumberSet.

Attributes

Returns

true if this is exact and belongs to set.

Inherited from:
NumberLike
def memberOf: Option[NumberSet]

Method to determine the NumberSet, if any, to which this NumberLike object belongs. NOTE that we don't yet support H, the quaternions.

Method to determine the NumberSet, if any, to which this NumberLike object belongs. NOTE that we don't yet support H, the quaternions.

Attributes

Returns

Some(numberSet) or None if it doesn't belong to any (for example, it is fuzzy).

Inherited from:
NumberLike
def multiply(x: Field): Field

Multiplies the current instance by another Field and returns the result. Handles special cases such as multiplication with zero, one, or specific constants.

Multiplies the current instance by another Field and returns the result. Handles special cases such as multiplication with zero, one, or specific constants.

NOTE this code seems almost identical to the times method in GeneralNumber CONSIDER combining them and using the Factor facilities more.

Value parameters

x

the Field instance to be multiplied with the current instance

Attributes

Returns

the result of the multiplication as a Field

Inherited from:
Number
def negateConditional(cond: Boolean): Number

Negates the value of the instance conditionally based on the input parameter.

Negates the value of the instance conditionally based on the input parameter.

Value parameters

cond

A boolean parameter that determines whether to negate the value. If true, the negation function makeNegative is applied. Otherwise, the current instance is returned unchanged.

Attributes

Returns

The negated value as a Number if the condition is true, or the current instance if the condition is false.

Inherited from:
Number
def noFuzz[U >: Double : HasValue]: Fuzziness[U]

Creates a fuzziness value with zero magnitude and a Gaussian distribution. This method provides a representation of deterministic or non-fuzzy values by ensuring that the fuzziness magnitude is explicitly zero.

Creates a fuzziness value with zero magnitude and a Gaussian distribution. This method provides a representation of deterministic or non-fuzzy values by ensuring that the fuzziness magnitude is explicitly zero.

Type parameters

U

a supertype of T that also satisfies the HasValue type class constraint.

Attributes

Returns

a Fuzziness[U] instance with zero magnitude and Gaussian shape.

Inherited from:
Fuzz
def power(p: Field): Field

Raise this Number to the power p.

Raise this Number to the power p.

Value parameters

p

a Field.

Attributes

Returns

this Number raised to power p.

Inherited from:
Number
def power(p: Number): Number

Attributes

Inherited from:
Number
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
def query[T](op: QueryOperation[T], defaultVal: => T): T

Evaluate a query operator on this.

Evaluate a query operator on this.

Value parameters

op

the appropriate QueryOperation.

Attributes

Returns

a Boolean.

Inherited from:
GeneralNumber
def scale(f: Factor): Number

Method to create a new version of this, but with factor f. NOTE: the result will have the same absolute magnitude as this. In other words, in the case where f is not factor, the numerical value of the result's value will be different from this value.

Method to create a new version of this, but with factor f. NOTE: the result will have the same absolute magnitude as this. In other words, in the case where f is not factor, the numerical value of the result's value will be different from this value.

Value parameters

f

the new factor for the result.

Attributes

Returns

a Number based on this and factor.

Inherited from:
GeneralNumber
def toLong: Option[Long]

Method to get the value of this Number as an Long.

Method to get the value of this Number as an Long.

Attributes

Returns

an Option of Long. If this Number cannot be converted to a Long, then None will be returned.

Inherited from:
Number

Evaluate a monadic operator on this.

Evaluate a monadic operator on this.

CONSIDER the exact cases don't change the fuzziness at all. But, if there is already fuzziness, then the monadic function should change it.

Value parameters

f

the factor to apply to the result.

op

the appropriate MonadicOperation.

Attributes

Returns

a new Number which is result of applying the appropriate function to the operand this.

Inherited from:
GeneralNumber
def unary_-: Field

Change the sign of this Number.

Change the sign of this Number.

Attributes

Inherited from:
Number

Concrete fields

lazy val isExact: Boolean

Method to determine if this NumberLike object is exact. For instance, Number.pi is exact, although if you converted it into a PureNumber, it would no longer be exact.

Method to determine if this NumberLike object is exact. For instance, Number.pi is exact, although if you converted it into a PureNumber, it would no longer be exact.

Attributes

Returns

true if this NumberLike object is exact in the context of No factor, else false.

lazy val isZero: Boolean

Attributes

Returns

true if this Number is equal to zero.

lazy val render: String

Render this ExactNumber as a String representation.

Render this ExactNumber as a String representation.

Attributes

Returns

the String representation of this ExactNumber.

lazy override val show: String

Show this ExactNumber in a human-friendly manner. Uses Unicode vulgar fraction characters for common rationals (½, ⅓, ¼, etc.), and falls back to render for everything else.

Show this ExactNumber in a human-friendly manner. Uses Unicode vulgar fraction characters for common rationals (½, ⅓, ¼, etc.), and falls back to render for everything else.

Attributes

Returns

a String

lazy val signum: Int

Method to determine the sense of this number: negative, zero, or positive.

Method to determine the sense of this number: negative, zero, or positive.

Attributes

Returns

an Int which is negative, zero, or positive according to the magnitude of this.

lazy val simplify: Number

Method to make some trivial simplifications of this ExactNumber.

Method to make some trivial simplifications of this ExactNumber.

Attributes

Returns

either this Number or a simplified Number.

lazy override val toString: String

Render this ExactNumber in String form, including the factor.

Render this ExactNumber in String form, including the factor.

Attributes

Returns

a String

Inherited fields

lazy val abs: Number

Method to yield the absolute value of this Number.

Method to yield the absolute value of this Number.

Attributes

Returns

this if its positive, else - this.

Inherited from:
GeneralNumber
lazy val asComplex: Complex

Method to return this Number as a Complex.

Method to return this Number as a Complex.

Attributes

Returns

Complex(this) as appropriate.

Inherited from:
Number
lazy val cos: Number

Method to determine the cosine of this Number. The result will be a Number with PureNumber factor.

Method to determine the cosine of this Number. The result will be a Number with PureNumber factor.

Attributes

Returns

the cosine.

Inherited from:
GeneralNumber
lazy val cosh: Number

Method to determine the cosine of this Number. The result will be a Number with PureNumber factor.

Method to determine the cosine of this Number. The result will be a Number with PureNumber factor.

Attributes

Returns

the cosine.

Inherited from:
GeneralNumber
lazy val exp: Number

Method to raise NatLog to the power of this number. The result will be a Number with NatLog factor.

Method to raise NatLog to the power of this number. The result will be a Number with NatLog factor.

Attributes

Returns

the e to the power of this.

Inherited from:
GeneralNumber
val fuzz: Option[Fuzziness[Double]]

Retrieves an optional fuzziness value associated with this instance.

Retrieves an optional fuzziness value associated with this instance.

The fuzziness value, if present, provides information about the level of uncertainty or imprecision, modeled as a Fuzziness[Double].

Attributes

Returns

an Option containing the Fuzziness[Double] value if defined, or None if no fuzziness is specified.

Inherited from:
GeneralNumber
lazy val getInverse: Number

Yields the inverse of this Number. This Number is first normalized so that its factor is PureNumber, since we cannot directly invert Numbers with other factors.

Yields the inverse of this Number. This Number is first normalized so that its factor is PureNumber, since we cannot directly invert Numbers with other factors.

CONSIDER allowing logarithmic numbers to be inverted simply by changing the sign of the value.

Attributes

Inherited from:
Number
lazy val invert: Field

Yields the inverse of this Number. This Number is first normalized so that its factor is PureNumber, since we cannot directly invert Numbers with other factors.

Yields the inverse of this Number. This Number is first normalized so that its factor is PureNumber, since we cannot directly invert Numbers with other factors.

CONSIDER allowing logarithmic numbers to be inverted simply by changing the sign of the value.

Attributes

Inherited from:
Number
lazy val isImaginary: Boolean

Method to determine if this is an imaginary Number, that's to say a number with negative nominalValue and SquareRoot as its factor.

Method to determine if this is an imaginary Number, that's to say a number with negative nominalValue and SquareRoot as its factor.

Attributes

Returns

true if imaginary.

Inherited from:
GeneralNumber
lazy val isInfinite: Boolean

Attributes

Returns

true if this Number is equal to zero.

Inherited from:
GeneralNumber
lazy val isInteger: Boolean

Method to determine if this Number is actually represented as an Integer.

Method to determine if this Number is actually represented as an Integer.

Attributes

Returns

true if exact and rational.

Inherited from:
GeneralNumber
lazy val isPositive: Boolean

Method to determine if this Number is positive. Use case: does the String representation not start with a "-"?

Method to determine if this Number is positive. Use case: does the String representation not start with a "-"?

CONSIDER evaluating toString instead.

Attributes

Returns

true if this Number is greater than or equal to 0.

Inherited from:
GeneralNumber
lazy val isRational: Boolean

Method to determine if this Number is actually represented as a Rational.

Method to determine if this Number is actually represented as a Rational.

Attributes

Returns

true if exact and rational.

Inherited from:
GeneralNumber
lazy val isUnity: Boolean

Attributes

Returns

true if the value of this GeneralNumber is one.

Inherited from:
GeneralNumber
lazy val isValid: Boolean

Method to determine if this is a valid Number. An invalid number has a value of form Left(Left(Left(None)))

Method to determine if this is a valid Number. An invalid number has a value of form Left(Left(Left(None)))

Attributes

Returns

true if this is a valid Number

Inherited from:
GeneralNumber
lazy val ln: Field

Method to determine the natural log of this Number. The result will be a Number with PureNumber factor.

Method to determine the natural log of this Number. The result will be a Number with PureNumber factor.

Attributes

Returns

the natural log of this.

Inherited from:
GeneralNumber
lazy val makeNegative: Number

Negative of this Number.

Negative of this Number.

Attributes

Inherited from:
GeneralNumber
lazy val modulate: Number

Method to ensure that the value is within some factor-specific range. In particular, Radian=based numbers are modulated to the range 0..2

Method to ensure that the value is within some factor-specific range. In particular, Radian=based numbers are modulated to the range 0..2

Attributes

Returns

this or an equivalent Number.

Inherited from:
GeneralNumber
lazy val normalize: Field

Method to "normalize" a number, that's to say make it a PureNumber and also to force any fuzziness to be absolute.

Method to "normalize" a number, that's to say make it a PureNumber and also to force any fuzziness to be absolute.

Attributes

Returns

a new Number with factor of PureNumber but with the same magnitude as this.

Inherited from:
GeneralNumber
lazy val sin: Number

Method to determine the sine of this Number. The result will be a Number with PureNumber factor.

Method to determine the sine of this Number. The result will be a Number with PureNumber factor.

Attributes

Returns

the sine of this.

Inherited from:
GeneralNumber
lazy val sinh: Number

Method to determine the sine of this Number. The result will be a Number with PureNumber factor.

Method to determine the sine of this Number. The result will be a Number with PureNumber factor.

Attributes

Returns

the sine of this.

Inherited from:
GeneralNumber
lazy val specialize: Number

Return a Number which uses the most restricted type possible. A Number based on a Double will yield a Number based on a Rational (if the conversion is exact). A Number based on a Rational will yield a Number based on a BigInt (if there is a unit denominator). A Number based on a BigInt will yield a Number based on a Int (if it is sufficiently small).

Return a Number which uses the most restricted type possible. A Number based on a Double will yield a Number based on a Rational (if the conversion is exact). A Number based on a Rational will yield a Number based on a BigInt (if there is a unit denominator). A Number based on a BigInt will yield a Number based on a Int (if it is sufficiently small).

Attributes

Returns

a Number with the same magnitude as this.

Inherited from:
GeneralNumber
lazy val sqrt: Number

Yields the square root of this Number. The result will be exact.

Yields the square root of this Number. The result will be exact.

Attributes

Inherited from:
GeneralNumber
lazy val square: Number

Calculates the square of a number by multiplying the number by itself. CONSIDER different implementations according to the factor.

Calculates the square of a number by multiplying the number by itself. CONSIDER different implementations according to the factor.

Attributes

Returns

the result of squaring this number

Inherited from:
Number
lazy val tan: Number

Method to determine the tangent of this Number. The result will be a Number with PureNumber factor. NOTE that not all cases have been tested.

Method to determine the tangent of this Number. The result will be a Number with PureNumber factor. NOTE that not all cases have been tested.

Attributes

Returns

the tangent

Inherited from:
Number
lazy val tanh: Number

Attributes

Inherited from:
GeneralNumber
lazy val toBigDecimal: Option[BigDecimal]

Method to get the nominalValue of this Number as an (optional) BigDecimal. This will return Some(x) only if this is an Int, or a Rational with unit denominator.

Method to get the nominalValue of this Number as an (optional) BigDecimal. This will return Some(x) only if this is an Int, or a Rational with unit denominator.

TESTME

Attributes

Returns

an Option of BigDecimal.

Inherited from:
GeneralNumber
lazy val toBigInt: Option[BigInt]

Method to get the nominalValue of this Number as an (optional) BigInt. This will return Some(x) only if this is an Int, or a Rational with unit denominator.

Method to get the nominalValue of this Number as an (optional) BigInt. This will return Some(x) only if this is an Int, or a Rational with unit denominator.

Attributes

Returns

an Option of BigInt.

Inherited from:
GeneralNumber
lazy val toInt: Option[Int]

Method to get the nominalValue of this Number as an Int.

Method to get the nominalValue of this Number as an Int.

Attributes

Returns

an Option of Int. If this Number cannot be converted to an Int, then None will be returned.

Inherited from:
GeneralNumber
lazy val toNominalDouble: Option[Double]

Method to get the nominalValue of this Number as an optional Double.

Method to get the nominalValue of this Number as an optional Double.

Attributes

Returns

an Some(Double) which is the closest possible nominalValue to the nominal nominalValue, otherwise None if this is invalid.

Inherited from:
Number
lazy val toNominalRational: Option[Rational]

Method to get the nominalValue of this Number as a Rational. If this is actually a Double, it will be converted to a Rational according to the implicit conversion from Double to Rational. See Rational.convertDouble(x).

Method to get the nominalValue of this Number as a Rational. If this is actually a Double, it will be converted to a Rational according to the implicit conversion from Double to Rational. See Rational.convertDouble(x).

Attributes

Returns

an Option of Rational.

Inherited from:
GeneralNumber
lazy val toPureNumber: Number

Converts the current number instance into a pure number representation. The conversion is based on the factor and fuzz values associated with the number. NOTE that even if this Number is exact, the result may not be.

Converts the current number instance into a pure number representation. The conversion is based on the factor and fuzz values associated with the number. NOTE that even if this Number is exact, the result may not be.

Attributes

Returns

A new instance of Number in pure number representation, performing the necessary conversion and scaling if required.

Inherited from:
Number