Modulo

com.phasmidsoftware.number.core.inner.Modulo
See theModulo companion trait
object Modulo

Attributes

Companion
trait
Graph
Supertypes
class Object
trait Matchable
class Any
Self type
Modulo.type

Members list

Type members

Classlikes

Boundary behavior for angles. Prefers max (π over -π) and treats -π ≡ π as equivalent.

Boundary behavior for angles. Prefers max (π over -π) and treats -π ≡ π as equivalent.

Note: This should be explicitly imported or defined where angles are used, as it overrides the default number behavior.

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type

Attributes

Supertypes
class Object
trait Matchable
class Any
Self type
object given_Modulo_BigDecimal extends Modulo[BigDecimal]

Given instance for BigDecimal.

Given instance for BigDecimal.

Attributes

Supertypes
trait Modulo[BigDecimal]
class Object
trait Matchable
class Any
Self type
object given_Modulo_Double extends Modulo[Double]

Given instance for Double.

Given instance for Double.

Attributes

Supertypes
trait Modulo[Double]
class Object
trait Matchable
class Any
Self type
object given_Modulo_Int extends Modulo[Int]

Given instance for Int.

Given instance for Int.

Attributes

Supertypes
trait Modulo[Int]
class Object
trait Matchable
class Any
Self type

Given instance for Rational numbers. Requires the RationalFloor extension to be in scope.

Given instance for Rational numbers. Requires the RationalFloor extension to be in scope.

Attributes

Supertypes
trait Modulo[Rational]
class Object
trait Matchable
class Any
Self type

Value members

Concrete methods

def apply[X](using m: Modulo[X]): Modulo[X]
def normalize[X](value: X, min: X, max: X, inclusive: Boolean, boundaryBehavior: BoundaryBehavior[X])(using m: Modulo[X]): X

Normalize a value into a range using modular arithmetic (with explicit boundary behavior). This replaces the recursive modulate function with an efficient modulo-based approach.

Normalize a value into a range using modular arithmetic (with explicit boundary behavior). This replaces the recursive modulate function with an efficient modulo-based approach.

The behavior is controlled by:

  • boundaryBehavior parameter: explicit boundary behavior (polarity and circular equivalence)
  • inclusive parameter: context-dependent choice of whether both endpoints are valid

Value parameters

boundaryBehavior

explicit boundary behavior for this normalization

inclusive

if true, both min and max are valid; if false, max is excluded

max

the maximum of the range

min

the minimum of the range

value

the value to normalize

Attributes

Returns

the normalized value in the appropriate range

def normalize[X](value: X, min: X, max: X, inclusive: Boolean)(using m: Modulo[X], b: BoundaryBehavior[X]): X

Normalize a value into a range using modular arithmetic (with implicit boundary behavior). This version uses implicit resolution to find the appropriate BoundaryBehavior.

Normalize a value into a range using modular arithmetic (with implicit boundary behavior). This version uses implicit resolution to find the appropriate BoundaryBehavior.

Value parameters

inclusive

if true, both min and max are valid; if false, max is excluded

max

the maximum of the range

min

the minimum of the range

value

the value to normalize

Attributes

Returns

the normalized value in the appropriate range

Givens

Givens

Given instance for BigDecimal.

Given instance for BigDecimal.

Attributes

Given instance for Double.

Given instance for Double.

Attributes

Given instance for Int.

Given instance for Int.

Attributes

Given instance for Rational numbers. Requires the RationalFloor extension to be in scope.

Given instance for Rational numbers. Requires the RationalFloor extension to be in scope.

Attributes