Trait to define the behavior of things that are number-like.
CONSIDER extending Ordered[NumberLike]
Attributes
- Companion
- object
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class Rationaltrait Numericaltrait Fieldtrait Multivariatetrait Complexclass BaseComplexclass ComplexCartesianclass ComplexPolarclass Realobject NaNtrait Numberclass GeneralNumberclass ExactNumberclass FuzzyNumberShow all
Members list
Value members
Abstract methods
Method to represent this NumberLike object as an optional Number. The result will be defined if: (1) we do not lose precision and (2) this object is not complex.
Method to represent this NumberLike object as an optional Number. The result will be defined if: (1) we do not lose precision and (2) this object is not complex.
NOTE: to force this as a Number, use convertToNumber in the companion Object.
CONSIDER redefining this as Option[Field] or Option[Real].
Attributes
- Returns
-
a Some(x) if this is a Number; otherwise return None.
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.
Method to determine what Factor, if there is such, this NumberLike object is based on. Unlike context, a None result is not permissive.
Method to determine what Factor, if there is such, this NumberLike object is based on. Unlike context, a None result is not permissive.
Attributes
- Returns
-
an optional
Factor.
Method to render this NumberLike in a presentable manner.
Method to render this NumberLike in a presentable manner.
Attributes
- Returns
-
a String
Concrete methods
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
NumberLikeobject is anExactNumberand its factor isPureNumber, the result is converted usingValue.asJavaNumber. - If the
NumberLikeobject is aFuzzyNumberwith awigglevalue below a specified tolerance, the result is also converted usingValue.asJavaNumber. - In all other cases,
Noneis returned.
Attributes
- Returns
-
an optional
java.lang.Numberrepresentation of this object. The result isSome(java.lang.Number)if the conversion is successful under the stated conditions; otherwise,None.
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).
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.
Method to show this NumberLike in a human-friendly manner. Subclasses may override for prettier output (vulgar fractions, dropped trailing zeros, etc.). The default falls back to render.
Method to show this NumberLike in a human-friendly manner. Subclasses may override for prettier output (vulgar fractions, dropped trailing zeros, etc.). The default falls back to render.
Attributes
- Returns
-
a String