QueryOperationSignum

com.phasmidsoftware.number.core.inner.QueryOperationSignum
case object QueryOperationSignum extends QueryOperation[Int]

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.

Attributes

Graph
Supertypes
trait Singleton
trait Product
trait Mirror
trait Serializable
trait Product
trait Equals
trait QueryOperation[Int]
class Object
trait Matchable
class Any
Show all
Self type

Members list

Type members

Inherited types

type MirroredElemLabels = EmptyTuple

The names of the product elements.

The names of the product elements.

Attributes

Inherited from:
Singleton
type MirroredElemTypes = EmptyTuple

Attributes

Inherited from:
Singleton
type MirroredMonoType = this.type

The mirrored *-type.

The mirrored *-type.

Attributes

Inherited from:
Singleton
type MirroredType = this.type

Attributes

Inherited from:
Singleton

Inherited and Abstract types

type MirroredLabel <: String

The name of the type.

The name of the type.

Attributes

Inherited from:
Mirror

Value members

Concrete methods

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.

Inherited methods

def fromProduct(p: Product): MirroredMonoType

Creates a new instance of type T with elements taken from product p.

Creates a new instance of type T with elements taken from product p.

Attributes

Inherited from:
Singleton
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