Module zinc::std::numExperimental [-]  [+] [src]

Numeric traits and functions for generic mathematics

Enums

FPCategory

Used for representing the classification of floating point numbers

Traits

Bounded

Numbers which have upper and lower bounds

CheckedAdd

Performs addition that returns None instead of wrapping around on overflow.

CheckedDiv

Performs division that returns None instead of failing on division by zero and instead of wrapping around on underflow and overflow.

CheckedMul

Performs multiplication that returns None instead of wrapping around on underflow or overflow.

CheckedSub

Performs subtraction that returns None instead of wrapping around on underflow.

Float

Operations on primitive floating point numbers.

FromPrimitive

A generic trait for converting a number to a value.

Int

A primitive signed or unsigned integer equipped with various bitwise operators, bit counting methods, and endian conversion functions.

Num

The base trait for numeric types

NumCast

An interface for casting between machine scalars.

One

Defines a multiplicative identity element for Self.

Primitive

Specifies the available operations common to all of Rust's core numeric primitives. These may not always make sense from a purely mathematical point of view, but may be useful for systems programming.

Saturating

Saturating math operations

Signed

Useful functions for signed numbers (i.e. numbers that can be negative).

ToPrimitive

A generic trait for converting a value to a number.

Unsigned

A trait for values which cannot be negative

Zero

Defines an additive identity element for Self.

Functions

abs

Computes the absolute value.

abs_sub

The positive difference of two numbers.

cast

Cast from one machine scalar to another.

checked_next_power_of_two

Returns the smallest power of 2 greater than or equal to n. If the next power of two is greater than the type's maximum value, None is returned, otherwise the power of 2 is wrapped in Some.

div_rem

Simultaneous division and remainder

from_f32

A utility function that just calls FromPrimitive::from_f32.

from_f64

A utility function that just calls FromPrimitive::from_f64.

from_i16

A utility function that just calls FromPrimitive::from_i16.

from_i32

A utility function that just calls FromPrimitive::from_i32.

from_i64

A utility function that just calls FromPrimitive::from_i64.

from_i8

A utility function that just calls FromPrimitive::from_i8.

from_int

A utility function that just calls FromPrimitive::from_int.

from_u16

A utility function that just calls FromPrimitive::from_u16.

from_u32

A utility function that just calls FromPrimitive::from_u32.

from_u64

A utility function that just calls FromPrimitive::from_u64.

from_u8

A utility function that just calls FromPrimitive::from_u8.

from_uint

A utility function that just calls FromPrimitive::from_uint.

is_power_of_two
next_power_of_two

Returns the smallest power of 2 greater than or equal to n.

one

Returns the multiplicative identity, 1.

pow

Raises a value to the power of exp, using exponentiation by squaring.

signum

Returns the sign of the number.

zero

Returns the additive identity, 0.