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 the lowercase 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 is Nearest.

  • 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 an f64 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 is true.

  • 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 is false.

  • 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

source

pub const fn get_base(&self) -> u8

Returns the base to be used in the conversion. It is always between 2 and 36, inclusive.

source

pub const fn get_rounding_mode(&self) -> RoundingMode

Returns the rounding mode to be used in the conversion.

source

pub const fn get_size_options(&self) -> SciSizeOptions

Returns the size options to be used in the conversion.

source

pub const fn get_neg_exp_threshold(&self) -> i64

Returns the exponent low threshold to be used in the conversion. It is always negative.

source

pub const fn get_lowercase(&self) -> bool

Returns whether the digits should be lowercase.

source

pub const fn get_e_lowercase(&self) -> bool

Returns whether the exponent indicator should be lowercase ('e' rather than 'E').

source

pub const fn get_force_exponent_plus_sign(&self) -> bool

Returns whether positive exponents should always be preceded by an explicit plus sign.

source

pub const fn get_include_trailing_zeros(&self) -> bool

Returns whether trailing zeros should be included after the decimal (or other-base) point.

source

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.

source

pub fn set_rounding_mode(&mut self, rm: RoundingMode)

Sets the rounding mode to be used in the conversion.

source

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.

source

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.

source

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.

source

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.

source

pub fn set_lowercase(&mut self)

Specifies that digits in bases greater than ten should be output with lowercase letters.

source

pub fn set_uppercase(&mut self)

Specifies that digits in bases greater than ten should be output with uppercase letters.

source

pub fn set_e_lowercase(&mut self)

Specifies that the exponent-indicating character should be 'e'.

source

pub fn set_e_uppercase(&mut self)

Specifies that the exponent-indicating character should be 'E'.

source

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'.

source

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

source§

fn clone(&self) -> ToSciOptions

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for ToSciOptions

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for ToSciOptions

source§

fn default() -> ToSciOptions

Returns the “default value” for a type. Read more
source§

impl PartialEq for ToSciOptions

source§

fn eq(&self, other: &ToSciOptions) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for ToSciOptions

source§

impl Eq for ToSciOptions

source§

impl StructuralPartialEq for ToSciOptions

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T, U> ExactFrom<T> for U
where U: TryFrom<T>,

source§

fn exact_from(value: T) -> U

source§

impl<T, U> ExactInto<U> for T
where U: ExactFrom<T>,

source§

fn exact_into(self) -> U

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> OverflowingInto<U> for T
where U: OverflowingFrom<T>,

source§

impl<T, U> RoundingInto<U> for T
where U: RoundingFrom<T>,

source§

impl<T, U> SaturatingInto<U> for T
where U: SaturatingFrom<T>,

source§

impl<T> ToDebugString for T
where T: Debug,

source§

fn to_debug_string(&self) -> String

Returns the String produced by Ts Debug implementation.

§Examples
use malachite_base::strings::ToDebugString;

assert_eq!([1, 2, 3].to_debug_string(), "[1, 2, 3]");
assert_eq!(
    [vec![2, 3], vec![], vec![4]].to_debug_string(),
    "[[2, 3], [], [4]]"
);
assert_eq!(Some(5).to_debug_string(), "Some(5)");
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T, U> WrappingInto<U> for T
where U: WrappingFrom<T>,

source§

fn wrapping_into(self) -> U