Skip to content

Num

Abstract supertype for numeric values.

Methods

abs[N @ Num]() -> N

Returns the magnitude of the value.

Raises OverflowError if the result is not representable.

Parameters

NameTypeDescription
self N Receiver.

ceil[N @ Num]() -> N

Rounds toward positive infinity.

Parameters

NameTypeDescription
self N Receiver.

clamp[N @ Num] lower upper -> N

Restricts the value to the inclusive interval from lower to upper.

Raises ValueError if lower > upper. If a comparison is unordered, which input is returned is unspecified.

Parameters

NameTypeDescription
self N Receiver.
lower N
upper N

floor[N @ Num]() -> N

Rounds toward negative infinity.

Parameters

NameTypeDescription
self N Receiver.

max[N @ Num] *others -> N

Returns the largest of this value and others.

If a comparison is unordered, which input is returned is unspecified.

Parameters

NameTypeDescription
self N Receiver.
*others N

min[N @ Num] *others -> N

Returns the smallest of this value and others.

If a comparison is unordered, which input is returned is unspecified.

Parameters

NameTypeDescription
self N Receiver.
*others N

round[N @ Num]() -> N

Rounds to the nearest integral value, with halfway cases away from zero.

Parameters

NameTypeDescription
self N Receiver.

signum[N @ Num]() -> N

Returns the signum of the value: negative one, zero, or positive one.

Parameters

NameTypeDescription
self N Receiver.

trunc[N @ Num]() -> N

Rounds toward zero.

Parameters

NameTypeDescription
self N Receiver.