[][src]Struct pgnumeric::Numeric

#[repr(transparent)]pub struct Numeric { /* fields omitted */ }

A slice of a numeric.

This is an unsized type, meaning that it must always be used behind a pointer like & or Box. For an owned version of this type, see NumericBuf.

Implementations

impl Numeric[src]

pub unsafe fn from_bytes_unchecked(value: &[u8]) -> &Numeric[src]

Creates a Numeric from bytes slice.

Safety

Caller have to guaranteed the value bytes slice is a valid Numeric.

pub fn nan() -> &'static Numeric[src]

Creates a NaN numeric.

pub fn zero() -> &'static Numeric[src]

Creates a zero numeric.

pub fn as_bytes(&self) -> &[u8][src]

Extracts a byte slice contains the entire numeric.

pub fn is_nan(&self) -> bool[src]

Checks if self is NaN.

pub fn is_negative(&self) -> bool[src]

Checks if self is negative.

pub fn is_positive(&self) -> bool[src]

Checks if self is positive.

pub fn scale(&self) -> Option<i32>[src]

Returns the scale, i.e. the count of decimal digits in the fractional part.

Returns None if self is NaN.

pub fn negate(&self) -> NumericBuf[src]

Negate this value.

pub fn signum(&self) -> NumericBuf[src]

Returns a numeric that represents the sign of self.

  • -1 if self is less than 0
  • 0 if self is equal to 0
  • 1 if self is greater than zero
  • NaN if self is NaN

pub fn inc(&self) -> NumericBuf[src]

Increment self by one.

Panics

Panics if overflows.

pub fn checked_add(&self, other: &Self) -> Option<NumericBuf>[src]

Add two numerics, returning None if overflow occurred.

pub fn checked_sub(&self, other: &Self) -> Option<NumericBuf>[src]

Subtract one numeric from another, returning None if overflow occurred.

pub fn checked_mul(&self, other: &Self) -> Option<NumericBuf>[src]

Calculate the product of two numerics, returning None if overflow occurred.

pub fn checked_div(&self, other: &Self) -> Option<NumericBuf>[src]

Checked numeric division. Computes self / other, returning None if other == 0 or the division results in overflow.

pub fn checked_div_trunc(&self, other: &Self) -> Option<NumericBuf>[src]

Computes self / other, truncating the result to an integer.

Returns None if other == 0 or the division results in overflow.

pub fn checked_rem(&self, other: &Self) -> Option<NumericBuf>[src]

Checked numeric remainder. Computes self % other, returning None if rhs == 0 or the division results in overflow.

pub fn round(&self, scale: i32) -> NumericBuf[src]

Round a value to have scale digits after the decimal point. We allow negative scale, implying rounding before the decimal point --- Oracle interprets rounding that way.

Panics

Panics if overflows.

pub fn trunc(&self, scale: i32) -> NumericBuf[src]

Truncate a value to have scale digits after the decimal point. We allow negative scale, implying a truncation before the decimal point --- Oracle interprets truncation that way.

pub fn ceil(&self) -> NumericBuf[src]

Return the smallest integer greater than or equal to the argument.

Panics

Panics if overflows.

pub fn floor(&self) -> NumericBuf[src]

Return the largest integer equal to or less than the argument.

Panics

Panics if overflows.

pub fn abs(&self) -> NumericBuf[src]

Compute the absolute value of self.

pub fn sqrt(&self) -> NumericBuf[src]

Compute the square root of a numeric.

Panics

Panics if self is negative.

pub fn ln(&self) -> NumericBuf[src]

Compute the natural logarithm of self.

Panics

Panics if self <= 0.

pub fn log(&self, base: &Self) -> NumericBuf[src]

Compute the logarithm of self in a given base.

Panics

Panics if self <= 0 or base <= 0.

pub fn log2(&self) -> NumericBuf[src]

Compute the base 2 logarithm of self.

Panics

Panics if self <= 0.

pub fn log10(&self) -> NumericBuf[src]

Compute the base 10 logarithm of self.

Panics

Panics if self <= 0.

pub fn exp(&self) -> Option<NumericBuf>[src]

Raise e to the power of self (e^(self)).

Returns None if overflows.

pub fn pow(&self, exp: &Self) -> Option<NumericBuf>[src]

Raise self to the power of exp.

Returns None if overflows.

Panics

if arguments are invalid:

  • self is zero and exp is less than zero
  • self is less than zero and exp is not a integer.

pub fn normalize(&self) -> String[src]

Returns a normalized string, suppressing insignificant trailing zeroes and then any trailing decimal point.

The intent of this is to produce strings that are equal if and only if the input numeric values compare equal.

Trait Implementations

impl<'_, '_> Add<&'_ Numeric> for &'_ NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the + operator.

impl<'_> Add<&'_ Numeric> for NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the + operator.

impl<'_, '_> Add<&'_ Numeric> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the + operator.

impl<'_, '_> Add<&'_ NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the + operator.

impl<'_> Add<NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the + operator.

impl<'_> AddAssign<&'_ Numeric> for NumericBuf[src]

impl AsRef<Numeric> for NumericBuf[src]

impl Borrow<Numeric> for NumericBuf[src]

impl Debug for Numeric[src]

impl Display for Numeric[src]

impl<'_, '_> Div<&'_ Numeric> for &'_ NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the / operator.

impl<'_> Div<&'_ Numeric> for NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the / operator.

impl<'_, '_> Div<&'_ Numeric> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the / operator.

impl<'_, '_> Div<&'_ NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the / operator.

impl<'_> Div<NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the / operator.

impl<'_> DivAssign<&'_ Numeric> for NumericBuf[src]

impl Eq for Numeric[src]

impl<'a> From<&'a Numeric> for Cow<'a, Numeric>[src]

impl Hash for Numeric[src]

impl LowerExp for Numeric[src]

impl<'_, '_> Mul<&'_ Numeric> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the * operator.

impl<'_> Mul<&'_ Numeric> for NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the * operator.

impl<'_, '_> Mul<&'_ Numeric> for &'_ NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the * operator.

impl<'_, '_> Mul<&'_ NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the * operator.

impl<'_> Mul<NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the * operator.

impl<'_> MulAssign<&'_ Numeric> for NumericBuf[src]

impl<'_> Neg for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the - operator.

impl Ord for Numeric[src]

impl<'_> PartialEq<&'_ Numeric> for NumericBuf[src]

impl<'_> PartialEq<&'_ Numeric> for Numeric[src]

impl PartialEq<Numeric> for Numeric[src]

impl PartialEq<Numeric> for NumericBuf[src]

impl<'_> PartialEq<Numeric> for &'_ Numeric[src]

impl PartialEq<NumericBuf> for Numeric[src]

impl<'_> PartialEq<NumericBuf> for &'_ Numeric[src]

impl<'_> PartialOrd<&'_ Numeric> for NumericBuf[src]

impl<'_> PartialOrd<&'_ Numeric> for Numeric[src]

impl PartialOrd<Numeric> for Numeric[src]

impl PartialOrd<Numeric> for NumericBuf[src]

impl<'_> PartialOrd<Numeric> for &'_ Numeric[src]

impl PartialOrd<NumericBuf> for Numeric[src]

impl<'_> PartialOrd<NumericBuf> for &'_ Numeric[src]

impl<'_, '_> Rem<&'_ Numeric> for &'_ NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the % operator.

impl<'_> Rem<&'_ Numeric> for NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the % operator.

impl<'_, '_> Rem<&'_ Numeric> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the % operator.

impl<'_, '_> Rem<&'_ NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the % operator.

impl<'_> Rem<NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the % operator.

impl<'_> RemAssign<&'_ Numeric> for NumericBuf[src]

impl<'_, '_> Sub<&'_ Numeric> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the - operator.

impl<'_> Sub<&'_ Numeric> for NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the - operator.

impl<'_, '_> Sub<&'_ Numeric> for &'_ NumericBuf[src]

type Output = NumericBuf

The resulting type after applying the - operator.

impl<'_, '_> Sub<&'_ NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the - operator.

impl<'_> Sub<NumericBuf> for &'_ Numeric[src]

type Output = NumericBuf

The resulting type after applying the - operator.

impl<'_> SubAssign<&'_ Numeric> for NumericBuf[src]

impl ToOwned for Numeric[src]

type Owned = NumericBuf

The resulting type after obtaining ownership.

impl<'_> TryFrom<&'_ Numeric> for i8[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for i16[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for isize[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for usize[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for f32[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for f64[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for i32[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for i64[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for i128[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for u8[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for u16[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for u32[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for u64[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl<'_> TryFrom<&'_ Numeric> for u128[src]

type Error = NumericTryFromError

The type returned in the event of a conversion error.

impl UpperExp for Numeric[src]

Auto Trait Implementations

impl RefUnwindSafe for Numeric

impl Send for Numeric

impl Sync for Numeric

impl Unpin for Numeric

impl UnwindSafe for Numeric

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]