given_Convertible_WholeNumber_Real

com.phasmidsoftware.number.algebra.eager.WholeNumber.given_Convertible_WholeNumber_Real

Represents a given instance of the Convertible typeclass to transform a Real into a WholeNumber, provided the Real value is exact and can be represented as a whole number.

The implementation leverages FP.recover to handle failures gracefully and will throw an AlgebraException if the provided Real cannot be converted into a WholeNumber.

The conversion is only possible if the Real value satisfies the following conditions:

  • It is marked as exact.
  • Its numerical value can be expressed as an integer.

Attributes

Returns

a WholeNumber instance representing the converted value.

Note

Throws an com.phasmidsoftware.number.algebra.util.AlgebraException if the input Real cannot be converted to a WholeNumber.

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

def convert(witness: WholeNumber, u: Real): WholeNumber

Transforms an instance of type U into type T by applying a specific operation, optionally using an additional parameter of type T.

Transforms an instance of type U into type T by applying a specific operation, optionally using an additional parameter of type T.

Value parameters

t

a template object of type T that might assist in the conversion

u

the source object of type U to be converted

Attributes

Returns

the converted object of type T