[−][src]Struct floating_bar::r32
The 32-bit floating bar type.
Methods
impl r32
[src]
pub fn numer(self) -> u32
[src]
Returns the numerator value for this rational number.
pub fn denom(self) -> u32
[src]
Returns the denominator value for this rational number.
pub fn floor(self) -> r32
[src]
Returns the largest integer less than or equal to a number.
pub fn ceil(self) -> r32
[src]
Returns the smallest integer greater than or equal to a number.
pub fn round(self) -> r32
[src]
Returns the nearest integer to a number. Round half-way cases away from 0
.
pub fn trunc(self) -> r32
[src]
Returns the integer part of a number.
pub fn fract(self) -> r32
[src]
Returns the fractional part of a number.
pub fn abs(self) -> r32
[src]
Computes the absolute value of self
. Returns NaN if the number is NaN.
pub fn signum(self) -> r32
[src]
Returns a number that represents the sign of self
.
1
if the number is positive-1
if the number is negative0
if the number is+0
,-0
, orNaN
pub fn pow(self, n: i32) -> r32
[src]
Raises a number to an integer power.
pub fn is_nan(self) -> bool
[src]
Returns true
if this value is NaN
and false
otherwise.
pub fn is_normal(self) -> bool
[src]
Returns true
if the number is neither zero, subnormal, or NaN
.
pub fn is_positive(self) -> bool
[src]
Returns true
if and only if self
has a positive sign, including
+0.0
(but not NaNs with positive sign bit).
pub fn is_negative(self) -> bool
[src]
Returns true
if and only if self has a negative sign, including
-0.0
(but not NaNs with negative sign bit).
pub fn recip(self) -> r32
[src]
Takes the reciprocal (inverse) of a number, 1/x
.
Panics
Panics when trying to set a numerator of zero as denominator.
pub fn max(self, other: r32) -> r32
[src]
Returns the maximum of the two numbers.
If one of the arguments is NaN
, then the other argument is returned.
pub fn min(self, other: r32) -> r32
[src]
Returns the minimum of the two numbers.
If one of the arguments is NaN
, then the other argument is returned.
pub fn to_bits(self) -> u32
[src]
Raw transmutation to u32
.
pub fn from_bits(bits: u32) -> r32
[src]
Raw transmutation from u32
.
pub fn simplify(self) -> r32
[src]
Cancels out common factors between the numerator and the denominator.
pub fn checked_add(self, rhs: r32) -> Option<r32>
[src]
Checked integer addition. Computes self + rhs
, returning None
if
overflow occurred.
pub fn checked_sub(self, rhs: r32) -> Option<r32>
[src]
Checked integer subtraction. Computes self - rhs
, returning None
if
overflow occurred.
pub fn checked_mul(self, rhs: r32) -> Option<r32>
[src]
Checked integer multiplication. Computes self * rhs
, returning None
if overflow occurred.
pub fn checked_div(self, rhs: r32) -> Option<r32>
[src]
Checked integer division. Computes self / rhs
, returning None
if
rhs == 0
or the division results in overflow.
pub fn checked_rem(self, rhs: r32) -> Option<r32>
[src]
Checked integer remainder. Computes self % rhs
, returning None
if
rhs == 0
or the division results in overflow.
pub fn overflowing_add(self, rhs: r32) -> (r32, bool)
[src]
Calculates self
+ rhs
Returns a tuple of the addition along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
pub fn overflowing_sub(self, rhs: r32) -> (r32, bool)
[src]
Calculates self
- rhs
Returns a tuple of the subtraction along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
pub fn overflowing_mul(self, rhs: r32) -> (r32, bool)
[src]
Calculates the multiplication of self
and rhs
.
Returns a tuple of the multiplication along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would have occurred then the wrapped value is returned.
pub fn overflowing_div(self, rhs: r32) -> (r32, bool)
[src]
Calculates the divisor when self
is divided by rhs
.
Returns a tuple of the divisor along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then self is returned.
Panics
This function will panic if rhs
is 0.
pub fn overflowing_rem(self, rhs: r32) -> (r32, bool)
[src]
Calculates the remainder when self
is divided by rhs
.
Returns a tuple of the remainder after dividing along with a boolean indicating whether an arithmetic overflow would occur. If an overflow would occur then 0 is returned.
Panics
This function will panic if rhs
is 0.
Trait Implementations
impl Eq for r32
[src]
impl Clone for r32
[src]
fn clone(&self) -> r32
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Into<f32> for r32
[src]
impl Into<f64> for r32
[src]
impl Copy for r32
[src]
impl PartialOrd<r32> for r32
[src]
fn partial_cmp(&self, other: &r32) -> Option<Ordering>
[src]
#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests greater than or equal to (for self
and other
) and is used by the >=
operator. Read more
impl PartialEq<r32> for r32
[src]
fn eq(&self, other: &r32) -> bool
[src]
#[must_use]
fn ne(&self, other: &Rhs) -> bool
1.0.0[src]
This method tests for !=
.
impl Default for r32
[src]
impl From<u8> for r32
[src]
impl From<i8> for r32
[src]
impl From<u16> for r32
[src]
impl From<i16> for r32
[src]
impl From<r32> for r64
[src]
impl Hash for r32
[src]
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl Add<r32> for r32
[src]
type Output = r32
The resulting type after applying the +
operator.
fn add(self, other: r32) -> r32
[src]
impl Sub<r32> for r32
[src]
type Output = r32
The resulting type after applying the -
operator.
fn sub(self, other: r32) -> r32
[src]
impl Mul<r32> for r32
[src]
type Output = r32
The resulting type after applying the *
operator.
fn mul(self, other: r32) -> r32
[src]
impl Div<r32> for r32
[src]
type Output = r32
The resulting type after applying the /
operator.
fn div(self, other: r32) -> r32
[src]
impl Rem<r32> for r32
[src]
type Output = r32
The resulting type after applying the %
operator.
fn rem(self, other: r32) -> r32
[src]
impl Neg for r32
[src]
type Output = r32
The resulting type after applying the -
operator.
fn neg(self) -> Self::Output
[src]
impl Debug for r32
[src]
impl Display for r32
[src]
impl FromStr for r32
[src]
type Err = ParseRatioErr
The associated error which can be returned from parsing.
fn from_str(src: &str) -> Result<Self, Self::Err>
[src]
Converts a string in base 10 to a rational.
This function accepts strings such as
- '157/50'
- '-157/50'
- '25', or equivalently, '25/1'
- 'NaN'
Leading and trailing whitespace represent an error.
Return value
Err(ParseRatioError)
if the string did not represent a valid number.
Otherwise, Ok(n)
where n
is the floating-bar number represented by
src
.
Auto Trait Implementations
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = !
try_from
)The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
try_from
)The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,