Struct scientific::Scientific
source · #[repr(transparent)]pub struct Scientific { /* private fields */ }Expand description
Arbitrary precision scientific number
See the module-level documentation for more details.
Implementations§
source§impl Scientific
impl Scientific
pub const ZERO: Scientific = _
pub const ONE: Scientific = _
pub fn from_string(source: String) -> Result<Scientific, ConversionError>
pub fn to_bytes(&self) -> Vec<u8>
pub fn from_bytes(bytes: &[u8]) -> Result<Scientific, ConversionError>
pub fn as_raw_mantissa(&self) -> &[u8] ⓘ
pub fn from_raw_parts( negative: bool, mantissa: Vec<u8>, exponent: isize ) -> Result<Scientific, ConversionError>
pub fn sqrt_truncate(&self, precision: Precision) -> Result<Scientific, Error>
pub fn sqrt_rpsp(&self, precision: Precision) -> Result<Scientific, Error>
pub fn abs(&self) -> Scientific
pub fn abs_assign(&mut self)
pub fn neg_assign(&mut self)
sourcepub fn div_truncate(
&self,
rhs: &Scientific,
precision: Precision
) -> Result<Scientific, Error>
pub fn div_truncate( &self, rhs: &Scientific, precision: Precision ) -> Result<Scientific, Error>
Please be aware that div_truncate is only calculating digits up to the specified precision.
For example 509/100 with a precision of 2 digits or 1 decimals will calculate 5.0 and not 5.1 as it’s may be expected with rounding in mind.
pub fn div_rem( &self, rhs: &Scientific ) -> Result<(Scientific, Scientific), Error>
sourcepub fn div_rpsp(
&self,
rhs: &Scientific,
precision: Precision
) -> Result<Scientific, Error>
pub fn div_rpsp( &self, rhs: &Scientific, precision: Precision ) -> Result<Scientific, Error>
Calculate division with included rpsp (Rounding to Prepare for Shorter Precision)
Use rpsp (Rounding to Prepare for Shorter Precision) only during internal calculations and do one “proper” round at the end of all calculations.
pub fn truncate_assign(&mut self, precision: Precision)
pub fn truncate(&self, precision: Precision) -> Scientific
pub fn round_assign(&mut self, precision: Precision, rounding: Rounding)
pub fn round(&self, precision: Precision, rounding: Rounding) -> Scientific
pub fn round_rpsp_assign(&mut self, precision: Precision)
pub fn round_rpsp(&self, precision: Precision) -> Scientific
pub fn len(&self) -> isize
pub fn decimals(&self) -> isize
pub fn exponent0(&self) -> isize
pub fn exponent1(&self) -> isize
pub fn exponent(&self) -> isize
pub fn powi(&self, exponent: usize) -> Scientific
pub fn is_zero(&self) -> bool
sourcepub fn is_sign_positive(&self) -> bool
pub fn is_sign_positive(&self) -> bool
Returns true if self has a positive sign, this excludes 0.
sourcepub fn is_sign_negative(&self) -> bool
pub fn is_sign_negative(&self) -> bool
Returns true if self has a negative sign, this excludes 0.
Trait Implementations§
source§impl Add<&Scientific> for &Scientific
impl Add<&Scientific> for &Scientific
source§impl Clone for Scientific
impl Clone for Scientific
source§fn clone(&self) -> Scientific
fn clone(&self) -> Scientific
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for Scientific
impl Debug for Scientific
source§impl<'de> Deserialize<'de> for Scientific
Available on crate feature serde only.
impl<'de> Deserialize<'de> for Scientific
Available on crate feature
serde only.source§fn deserialize<D>(
deserializer: D
) -> Result<Self, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>( deserializer: D ) -> Result<Self, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for Scientific
impl Display for Scientific
source§impl From<&Scientific> for f32
impl From<&Scientific> for f32
source§fn from(value: &Scientific) -> Self
fn from(value: &Scientific) -> Self
Converts to this type from the input type.
source§impl From<&Scientific> for f64
impl From<&Scientific> for f64
source§fn from(value: &Scientific) -> Self
fn from(value: &Scientific) -> Self
Converts to this type from the input type.
source§impl From<i128> for Scientific
impl From<i128> for Scientific
source§impl From<i16> for Scientific
impl From<i16> for Scientific
source§impl From<i32> for Scientific
impl From<i32> for Scientific
source§impl From<i64> for Scientific
impl From<i64> for Scientific
source§impl From<i8> for Scientific
impl From<i8> for Scientific
source§impl From<isize> for Scientific
impl From<isize> for Scientific
source§impl From<u128> for Scientific
impl From<u128> for Scientific
source§impl From<u16> for Scientific
impl From<u16> for Scientific
source§impl From<u32> for Scientific
impl From<u32> for Scientific
source§impl From<u64> for Scientific
impl From<u64> for Scientific
source§impl From<u8> for Scientific
impl From<u8> for Scientific
source§impl From<usize> for Scientific
impl From<usize> for Scientific
source§impl FromStr for Scientific
impl FromStr for Scientific
source§impl Hash for &Scientific
impl Hash for &Scientific
source§impl Mul<&Scientific> for &Scientific
impl Mul<&Scientific> for &Scientific
source§impl Neg for &Scientific
impl Neg for &Scientific
source§impl Ord for Scientific
impl Ord for Scientific
source§impl PartialEq<Scientific> for Scientific
impl PartialEq<Scientific> for Scientific
source§impl PartialOrd<Scientific> for Scientific
impl PartialOrd<Scientific> for Scientific
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self and other) and is used by the <=
operator. Read moresource§impl Serialize for Scientific
Available on crate feature serde only.
impl Serialize for Scientific
Available on crate feature
serde only.source§fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,
Serialize this value into the given Serde serializer. Read more
source§impl Shl<isize> for &Scientific
impl Shl<isize> for &Scientific
source§impl ShlAssign<isize> for Scientific
impl ShlAssign<isize> for Scientific
source§fn shl_assign(&mut self, rhs: isize)
fn shl_assign(&mut self, rhs: isize)
Performs the
<<= operation. Read moresource§impl Shr<isize> for &Scientific
impl Shr<isize> for &Scientific
source§impl ShrAssign<isize> for Scientific
impl ShrAssign<isize> for Scientific
source§fn shr_assign(&mut self, rhs: isize)
fn shr_assign(&mut self, rhs: isize)
Performs the
>>= operation. Read moresource§impl Sub<&Scientific> for &Scientific
impl Sub<&Scientific> for &Scientific
source§impl TryFrom<&Scientific> for i128
impl TryFrom<&Scientific> for i128
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for i16
impl TryFrom<&Scientific> for i16
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for i32
impl TryFrom<&Scientific> for i32
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for i64
impl TryFrom<&Scientific> for i64
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for i8
impl TryFrom<&Scientific> for i8
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for isize
impl TryFrom<&Scientific> for isize
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for u128
impl TryFrom<&Scientific> for u128
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for u16
impl TryFrom<&Scientific> for u16
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for u32
impl TryFrom<&Scientific> for u32
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for u64
impl TryFrom<&Scientific> for u64
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for u8
impl TryFrom<&Scientific> for u8
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<&Scientific> for usize
impl TryFrom<&Scientific> for usize
§type Error = ConversionError
type Error = ConversionError
The type returned in the event of a conversion error.
source§impl TryFrom<f32> for Scientific
impl TryFrom<f32> for Scientific
source§impl TryFrom<f64> for Scientific
impl TryFrom<f64> for Scientific
impl Eq for Scientific
impl Send for Scientific
Available on crate feature
arc only.impl Sync for Scientific
Available on crate feature
arc only.Auto Trait Implementations§
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more