number

o1.util.nice.number
object number

Provides nice extensions to the interface of basic numerical types, for convenience.

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type
number.type

Members list

Value members

Concrete methods

def ascending(a: Int, b: Int): (Int, Int)
def max(ints: Int*): Int
def min(ints: Int*): Int

Extensions

Extensions

extension (value: Int)
infix inline def %%(divisor: Int): Int

Produces a modulo while dealing nicely with negative values. myInt1 %% myInt2 is the remainder of the division myInt1 / myInt2 such that the division floors negative results away from zero rather than truncating them towards it. This has the effect that if myInt2 is positive, the result is always positive or zero.

Produces a modulo while dealing nicely with negative values. myInt1 %% myInt2 is the remainder of the division myInt1 / myInt2 such that the division floors negative results away from zero rather than truncating them towards it. This has the effect that if myInt2 is positive, the result is always positive or zero.

A typical use for this is when values (e.g., indices) need to be wrapped around to a zero-based range. For example, supposing size is positive, (myIndex + offset) %% size produces a valid index between 0 and size - 1, even if the sum is negative.

Attributes

infix inline def atLeast(minimum: Int): Int

num atLeast limit is equivalent to num.max(limit).

num atLeast limit is equivalent to num.max(limit).

Attributes

infix inline def atMost(maximum: Int): Int

num atMost limit is equivalent to num.min(limit).

num atMost limit is equivalent to num.min(limit).

Attributes

inline def clamp(low: Int, high: Int): Int

num.clamp(low, high) is equivalent to num.max(low).min(high).

num.clamp(low, high) is equivalent to num.max(low).min(high).

Attributes

infix inline def ddiv(divisor: Int): Double

myInt1 ddiv myInt2 is equivalent tomyInt1 / myInt2.toDouble`.

myInt1 ddiv myInt2 is equivalent tomyInt1 / myInt2.toDouble`.

Attributes

inline def isBetween(low: Int, high: Int): Boolean

Determines if the at least as large as low and less than high. Note that the lower bound is inclusive and the upper bound exclusive.

Determines if the at least as large as low and less than high. Note that the lower bound is inclusive and the upper bound exclusive.

Attributes

inline def isEven: Boolean

Determines if the integer is divisible by two.

Determines if the integer is divisible by two.

Attributes

inline def isOdd: Boolean

Determines if the integer isn’t divisible by two.

Determines if the integer isn’t divisible by two.

Attributes

extension (value: Double)
infix inline def atLeast(minimum: Double): Double

num atLeast limit is equivalent to num.max(limit).

num atLeast limit is equivalent to num.max(limit).

Attributes

infix inline def atMost(maximum: Double): Double

num atMost limit is equivalent to num.min(limit).

num atMost limit is equivalent to num.min(limit).

Attributes

inline def clamp(low: Double, high: Double): Double

num.clamp(low, high) is equivalent to num.max(low).min(high).

num.clamp(low, high) is equivalent to num.max(low).min(high).

Attributes

Determines if the at least as large as low and less than high. The lower bound is inclusive and the upper bound exclusive.

Determines if the at least as large as low and less than high. The lower bound is inclusive and the upper bound exclusive.

Attributes

extension (value: Float)
infix inline def atLeast(minimum: Float): Float

num atLeast limit is equivalent to num.max(limit).

num atLeast limit is equivalent to num.max(limit).

Attributes

infix inline def atMost(maximum: Float): Float

num atMost limit is equivalent to num.min(limit).

num atMost limit is equivalent to num.min(limit).

Attributes

inline def clamp(low: Float, high: Float): Float

num.clamp(low, high) is equivalent to num.max(low).min(high).

num.clamp(low, high) is equivalent to num.max(low).min(high).

Attributes

inline def isBetween(low: Float, high: Float): Boolean

Determines if the at least as large as low and less than high. The lower bound is inclusive and the upper bound exclusive.

Determines if the at least as large as low and less than high. The lower bound is inclusive and the upper bound exclusive.

Attributes

extension (value: Long)
infix inline def atLeast(minimum: Long): Long

num atLeast limit is equivalent to num.max(limit).

num atLeast limit is equivalent to num.max(limit).

Attributes

infix inline def atMost(maximum: Long): Long

num atMost limit is equivalent to num.min(limit).

num atMost limit is equivalent to num.min(limit).

Attributes

inline def clamp(low: Long, high: Long): Long

num.clamp(low, high) is equivalent to num.max(low).min(high).

num.clamp(low, high) is equivalent to num.max(low).min(high).

Attributes

inline def isBetween(low: Long, high: Long): Boolean

Determines if the at least as large as low and less than high. The lower bound is inclusive and the upper bound exclusive.

Determines if the at least as large as low and less than high. The lower bound is inclusive and the upper bound exclusive.

Attributes

inline def isEven: Boolean

Determines if the integer is divisible by two.

Determines if the integer is divisible by two.

Attributes

inline def isOdd: Boolean

Determines if the integer isn’t divisible by two.

Determines if the integer isn’t divisible by two.

Attributes