QueryOperationSignum is a concrete implementation of QueryOperation for integer results. It provides functionality to compute the signum of a numeric value (positive, negative, or zero) for various numeric types: Int, Rational, and Double.
The class defines a set of query functions encapsulated in an IntQueryFunctions instance. These functions leverage the math.signum operation for Int and Double, and the .signum method for Rational, with error handling provided through Try.
Specifically:
For Int inputs, it uses math.signum directly.
For Rational inputs, it computes the signum using the signum method of Rational.
For Double inputs, it uses math.signum and converts the result to an integer.
Returns a set of query functions that compute the signum of numeric values for Int, Rational, and Double inputs, encapsulated in an IntQueryFunctions instance.
Returns a set of query functions that compute the signum of numeric values for Int, Rational, and Double inputs, encapsulated in an IntQueryFunctions instance.
These functions use the following logic:
fInt: Computes the signum of an Int value using math.signum.
fRat: Computes the signum of a Rational value using the signum method of Rational.
fDouble: Computes the signum of a Double value using math.signum and converts the result to an Int.
Each function captures the result in a Try to safely handle potential errors during computation.
Attributes
Returns
an instance of IntQueryFunctions containing the three signum computation functions.