Value
This object provides methods related to the type Value.
Attributes
- Graph
-
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
Value.type
Members list
Value members
Concrete methods
Method to get the sign of a Value.
Method to get the sign of a Value.
Value parameters
- value
-
the value whose sign we need.
Attributes
- Returns
-
an Int.
Adds two Value instances and returns the result.
Adds two Value instances and returns the result.
The method attempts to perform addition by considering various combinations of Value types. If the addition cannot be performed, an invalid Value is returned.
Value parameters
- v1
-
the first
Valueto be added - v2
-
the second
Valueto be added
Attributes
- Returns
-
a
Valuerepresenting the sum ofv1andv2
Converts a Value into an optional java.lang.Number. This method attempts to map the given Value to a corresponding Number type in the following order:
Converts a Value into an optional java.lang.Number. This method attempts to map the given Value to a corresponding Number type in the following order:
- If the
Valuecan be represented as anInt, the result will be wrapped as ajava.lang.Number. - If the
Valueis aRationalthat can be accurately represented as aDouble, it is converted and wrapped as ajava.lang.Number. - If the
Valueis already aDouble, it will be directly wrapped as ajava.lang.Number. - If none of the above conversions are applicable,
Noneis returned.
CONSIDER using other methods from this class to get an appropriate Double.
Value parameters
- x
-
the
Valueto be converted.
Attributes
- Returns
-
an
Optioncontaining thejava.lang.Numberrepresentation of the givenValue, orNoneif conversion is not possible.
Convert an Option[Double] to a Value.
Convert an Option[Double] to a Value.
Value parameters
- xo
-
a Double.
Attributes
- Returns
-
a Value.
Convert an Int to a Value.
Convert an Int to a Value.
Value parameters
- x
-
an Int.
Attributes
- Returns
-
a Value.
Converts a Rational number into a Value.
Converts a Rational number into a Value.
Value parameters
- x
-
the Rational number to be converted.
Attributes
- Returns
-
a Value, which is either a Right containing an Int if the Rational can be precisely represented as an Int, or a Left containing the original Rational if not.
Computes the inverse of the given Value, if possible.
Computes the inverse of the given Value, if possible.
For numeric values, this method attempts to determine their inverse. If the input Value is a Double, None is returned.
Value parameters
- value
-
the Value to invert.
Attributes
- Returns
-
an Option containing the inverted Value, or None if the inversion cannot be performed.
Compares two Value instances to check if they are equal based on specific transformations and operations.
Compares two Value instances to check if they are equal based on specific transformations and operations.
Value parameters
- v1
-
the nominal
Valueagainst whichvis compared. - v2
-
the
Valueto be compared with thenominalValue.
Attributes
- Returns
-
trueif the transformed and composed values result in equality after performing operations, otherwisefalse.
Determines whether the given Value represents the numeric value zero. It doesn't matter whether the Value is a Double, Int or a Rational.
Determines whether the given Value represents the numeric value zero. It doesn't matter whether the Value is a Double, Int or a Rational.
Value parameters
- value
-
the Value to be checked.
Attributes
- Returns
-
true if the Value represents zero, otherwise false.
Method to (optionally) convert a Value into a Double.
Method to (optionally) convert a Value into a Double.
Value parameters
- value
-
the Value to be represented as a Double.
Attributes
- Returns
-
Some(x) where x is a Double if the conversion was possible, otherwise None.
An optional Int that corresponds to the value of this Number (but ignoring the factor).
An optional Int that corresponds to the value of this Number (but ignoring the factor).
CONSIDER using query
Attributes
An optional Rational that corresponds to the value of this Number (but ignoring the factor). A Double value 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 value of this Number (but ignoring the factor). A Double value is not converted to a Rational since, if it could be done exactly, it already would have been. CONSIDER using query
Attributes
Multiplies two Value instances and returns the result.
Multiplies two Value instances and returns the result.
This method attempts to perform multiplication by considering various combinations of Value types. If the multiplication cannot be performed, an invalid Value is returned.
Value parameters
- v1
-
the first
Valueto be multiplied - v2
-
the second
Valueto be multiplied
Attributes
- Returns
-
a
Valuerepresenting the product ofv1andv2
Negates the given Value.
Negates the given Value.
Value parameters
- value
-
the Value to be negated.
Attributes
- Returns
-
a Value representing the negation of the given Value.
Conditionally negates the provided Value based on the boolean parameter neg. If neg is true, the Value is negated using the negate method. Otherwise, the original Value is returned unchanged.
Conditionally negates the provided Value based on the boolean parameter neg. If neg is true, the Value is negated using the negate method. Otherwise, the original Value is returned unchanged.
Value parameters
- neg
-
a Boolean indicating whether the
Valueshould be negated. - value
-
the
Valueto be conditionally negated.
Attributes
- Returns
-
the negated
Valueifnegis true, otherwise the originalValue.
Method to scale the given Double according to the provided scaling factors.
Method to scale the given Double according to the provided scaling factors.
Value parameters
- fResult
-
the value of the factor that the result will be associated with.
- fThis
-
the value of the factor that x is associated with.
- x
-
the Double to be scaled.
Attributes
- Returns
-
a Double which will be paired with fResult.
Scales a Value by the given Rational factor.
Scales a Value by the given Rational factor.
The method attempts to scale a Value based on its internal type (e.g., Rational or Double). If the Value can be represented as a Rational, it is multiplied by the given scaling factor. Otherwise, if it can be represented as a Double, the scaling is applied in the Double domain.
Value parameters
- value
-
the
Valueto be scaled. - x
-
the
Rationalfactor by which theValueis scaled.
Attributes
- Returns
-
a new scaled
Value. The result is based on either the Rational or Double representation of the input value.
Method to get the sign of a Value.
Method to get the sign of a Value.
Value parameters
- value
-
the value whose sign we need.
Attributes
- Returns
-
an Int.
A variable-element unapply method which will yield an optional array. If there is only one item returned, it is an Int; if there are two items returned, they are null followed by a Rational; if there are three items returned, they are two nulls followed by a Double; otherwise, if the given value is not defined, then None is returned.
A variable-element unapply method which will yield an optional array. If there is only one item returned, it is an Int; if there are two items returned, they are null followed by a Rational; if there are three items returned, they are two nulls followed by a Double; otherwise, if the given value is not defined, then None is returned.
Value parameters
- v
-
the value.
Attributes
- Returns
-
Some(List[Int](x))orSome(List[Rational](null,x))orSome(List[Double](null,null,x))orNone.
Converts a given Value into its string representation, with options to skip certain outputs or use exact formatting.
Converts a given Value into its string representation, with options to skip certain outputs or use exact formatting.
Value parameters
- exact
-
a Boolean (default is true) specifying whether the string representation should be exact or adjusted with additional formatting (e.g., appending a "*").
- skipOne
-
a Boolean indicating whether to skip returning the string representation if the value equals "1" (only when
exactis true). - v
-
the
Valueto be converted into a string.
Attributes
- Returns
-
a
Stringrepresenting theValue, formatted according to the given parameters.
Concrete fields
A pre-defined constant Value representing one-half. This Value is derived from the Rational representation of half (1/2).
A pre-defined constant Value representing one-half. This Value is derived from the Rational representation of half (1/2).
It is created using the fromRational method to ensure an appropriate Value representation of the rational number one-half.
Attributes
Represents a predefined Value wrapping the integer 1 as a Right.
Represents a predefined Value wrapping the integer 1 as a Right.
Attributes
Represents the value 2 as a Value type, where Right(2) signifies a valid integer representation wrapped in a Right, indicating successful creation as a Value.
Represents the value 2 as a Value type, where Right(2) signifies a valid integer representation wrapped in a Right, indicating successful creation as a Value.
Attributes
Represents a predefined constant Value instance associated with the numeric value zero. The Value is constructed as a Right type containing the integer 0.
Represents a predefined constant Value instance associated with the numeric value zero. The Value is constructed as a Right type containing the integer 0.