Struct malachite_base::num::conversion::string::options::ToSciOptions
source · pub struct ToSciOptions { /* private fields */ }
Expand description
A struct
determining how a number should be formatted as a “scientific” string.
-
The base must be between 2 and 36, inclusive. The characters representing the digits are
'0'
through'9'
and either'a'
through'z'
or'A'
through'Z'
, depending on whether thelowercase
field is set. The default base is 10. -
The rounding mode determines how the output should be rounded, in case the
size_options
field is such that the number can’t be fully represented. The default rounding mode isNearest
. -
The size options determine the precision or scale that the number should be displayed with. The default is
Precision(16)
, which is about as much precision as anf64
is usually displayed with. -
The negative exponent threshold determines when small numbers switch to scientific notation. The default is $-6$, meaning that the numbers $1/10, 1/100, 1/1000, \ldots$. would be displayed as
0.1, 0.01, 0.001, 0.0001, 0.00001, 1e-6, 1e-7...
. The threshold must be negative. -
The lowercase setting determines whether digits in bases greater than 10 are lowercase or uppercase. The default is
true
. -
The exponent lowercase setting determines whether the exponent indicator is lowercase (
'e'
) or uppercase ('E'
). The default istrue
. -
The “force exponent plus sign” setting determines whether positive exponents should be rendered with an explicit plus sign. If the base is 15 or greater, then the explicit plus sign is used regardless, in order to distinguish the exponent indicator from the digit
'e'
. The default isfalse
. -
The “include trailing zeros” setting determines whether trailing zeros after the decimal (or other-base) point should be included. The default is
false
.
Implementations§
source§impl ToSciOptions
impl ToSciOptions
sourcepub const fn get_base(&self) -> u8
pub const fn get_base(&self) -> u8
Returns the base to be used in the conversion. It is always between 2 and 36, inclusive.
sourcepub const fn get_rounding_mode(&self) -> RoundingMode
pub const fn get_rounding_mode(&self) -> RoundingMode
Returns the rounding mode to be used in the conversion.
sourcepub const fn get_size_options(&self) -> SciSizeOptions
pub const fn get_size_options(&self) -> SciSizeOptions
Returns the size options to be used in the conversion.
sourcepub const fn get_neg_exp_threshold(&self) -> i64
pub const fn get_neg_exp_threshold(&self) -> i64
Returns the exponent low threshold to be used in the conversion. It is always negative.
sourcepub const fn get_lowercase(&self) -> bool
pub const fn get_lowercase(&self) -> bool
Returns whether the digits should be lowercase.
sourcepub const fn get_e_lowercase(&self) -> bool
pub const fn get_e_lowercase(&self) -> bool
Returns whether the exponent indicator should be lowercase ('e'
rather than 'E'
).
sourcepub const fn get_force_exponent_plus_sign(&self) -> bool
pub const fn get_force_exponent_plus_sign(&self) -> bool
Returns whether positive exponents should always be preceded by an explicit plus sign.
sourcepub const fn get_include_trailing_zeros(&self) -> bool
pub const fn get_include_trailing_zeros(&self) -> bool
Returns whether trailing zeros should be included after the decimal (or other-base) point.
sourcepub fn set_base(&mut self, base: u8)
pub fn set_base(&mut self, base: u8)
Sets the base to be used in the conversion.
§Panics
Panics if base
is less than 2 or greater than 36.
sourcepub fn set_rounding_mode(&mut self, rm: RoundingMode)
pub fn set_rounding_mode(&mut self, rm: RoundingMode)
Sets the rounding mode to be used in the conversion.
sourcepub fn set_size_complete(&mut self)
pub fn set_size_complete(&mut self)
Sets the size options to the “Complete” mode, indicating that the number should be converted using its full precision.
sourcepub fn set_precision(&mut self, precision: u64)
pub fn set_precision(&mut self, precision: u64)
Sets the size options to some precision, or number of significant digits.
§Panics
Panics if precision
is zero.
sourcepub fn set_scale(&mut self, scale: u64)
pub fn set_scale(&mut self, scale: u64)
Sets the size options to some scale, or number of digits after the decimal (or other-base) point.
sourcepub fn set_neg_exp_threshold(&mut self, neg_exp_threshold: i64)
pub fn set_neg_exp_threshold(&mut self, neg_exp_threshold: i64)
Sets the threshold at which nonzero numbers with a small absolute value start being represented using negative exponents.
sourcepub fn set_lowercase(&mut self)
pub fn set_lowercase(&mut self)
Specifies that digits in bases greater than ten should be output with lowercase letters.
sourcepub fn set_uppercase(&mut self)
pub fn set_uppercase(&mut self)
Specifies that digits in bases greater than ten should be output with uppercase letters.
sourcepub fn set_e_lowercase(&mut self)
pub fn set_e_lowercase(&mut self)
Specifies that the exponent-indicating character should be 'e'
.
sourcepub fn set_e_uppercase(&mut self)
pub fn set_e_uppercase(&mut self)
Specifies that the exponent-indicating character should be 'E'
.
sourcepub fn set_force_exponent_plus_sign(&mut self, force_exponent_plus_sign: bool)
pub fn set_force_exponent_plus_sign(&mut self, force_exponent_plus_sign: bool)
Sets whether a positive exponent should be preceded by an explicit plus sign.
If the base is 15 or greater, an explicit plus sign will be used regardless, in order to
differentiate the exponent-indicating character from the digit 'e'
.
sourcepub fn set_include_trailing_zeros(&mut self, include_trailing_zeros: bool)
pub fn set_include_trailing_zeros(&mut self, include_trailing_zeros: bool)
Sets whether trailing zeros after the decimal (or other-base) point should be included.
Trait Implementations§
source§impl Clone for ToSciOptions
impl Clone for ToSciOptions
source§fn clone(&self) -> ToSciOptions
fn clone(&self) -> ToSciOptions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for ToSciOptions
impl Debug for ToSciOptions
source§impl Default for ToSciOptions
impl Default for ToSciOptions
source§fn default() -> ToSciOptions
fn default() -> ToSciOptions
source§impl PartialEq for ToSciOptions
impl PartialEq for ToSciOptions
impl Copy for ToSciOptions
impl Eq for ToSciOptions
impl StructuralPartialEq for ToSciOptions
Auto Trait Implementations§
impl Freeze for ToSciOptions
impl RefUnwindSafe for ToSciOptions
impl Send for ToSciOptions
impl Sync for ToSciOptions
impl Unpin for ToSciOptions
impl UnwindSafe for ToSciOptions
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
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)
clone_to_uninit
)source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more