Struct fixed_decimal::scientific::ScientificDecimal
source · pub struct ScientificDecimal {
significand: FixedDecimal,
exponent: FixedInteger,
}
Expand description
A struct containing a FixedDecimal
significand together with an exponent, representing a
number written in scientific notation, such as 1.729×10³.
This structure represents any 0s shown in the significand and exponent,
and an optional sign for both the significand and the exponent.
Fields§
§significand: FixedDecimal
§exponent: FixedInteger
Implementations§
source§impl ScientificDecimal
impl ScientificDecimal
pub fn from(significand: FixedDecimal, exponent: FixedInteger) -> Self
Trait Implementations§
source§impl Clone for ScientificDecimal
impl Clone for ScientificDecimal
source§fn clone(&self) -> ScientificDecimal
fn clone(&self) -> ScientificDecimal
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 ScientificDecimal
impl Debug for ScientificDecimal
source§impl Display for ScientificDecimal
impl Display for ScientificDecimal
This trait is implemented for compatibility with fmt!
.
To create a string, [Writeable::write_to_string
] is usually more efficient.
source§impl FromStr for ScientificDecimal
impl FromStr for ScientificDecimal
source§impl PartialEq for ScientificDecimal
impl PartialEq for ScientificDecimal
source§impl TryFrom<&[u8]> for ScientificDecimal
impl TryFrom<&[u8]> for ScientificDecimal
source§impl Writeable for ScientificDecimal
impl Writeable for ScientificDecimal
Render the ScientificDecimal
as a string of ASCII digits with a possible decimal point,
followed by the letter ‘e’, and the exponent.
§Examples
assert_writeable_eq!(
ScientificDecimal::from(
FixedDecimal::from(1729).multiplied_pow10(-3),
FixedInteger::from(3)
),
"1.729e3"
);
assert_writeable_eq!(
ScientificDecimal::from(
FixedDecimal::from_str("+1.729").unwrap(),
FixedInteger::from_str("+03").unwrap()
),
"+1.729e+03"
);
source§fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
fn write_to<W: Write + ?Sized>(&self, sink: &mut W) -> Result
Writes a string to the given sink. Errors from the sink are bubbled up.
The default implementation delegates to
write_to_parts
, and discards any
Part
annotations.source§fn writeable_length_hint(&self) -> LengthHint
fn writeable_length_hint(&self) -> LengthHint
Returns a hint for the number of UTF-8 bytes that will be written to the sink. Read more
source§fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where
S: PartsWrite + ?Sized,
fn write_to_parts<S>(&self, sink: &mut S) -> Result<(), Error>where
S: PartsWrite + ?Sized,
Write bytes and
Part
annotations to the given sink. Errors from the
sink are bubbled up. The default implementation delegates to write_to
,
and doesn’t produce any Part
annotations.impl StructuralPartialEq for ScientificDecimal
Auto Trait Implementations§
impl Freeze for ScientificDecimal
impl RefUnwindSafe for ScientificDecimal
impl Send for ScientificDecimal
impl Sync for ScientificDecimal
impl Unpin for ScientificDecimal
impl UnwindSafe for ScientificDecimal
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)