Trait malachite_base::num::conversion::traits::ToSci

source ·
pub trait ToSci: Sized {
    // Required methods
    fn fmt_sci(&self, f: &mut Formatter<'_>, options: ToSciOptions) -> Result;
    fn fmt_sci_valid(&self, options: ToSciOptions) -> bool;

    // Provided methods
    fn to_sci_with_options(&self, options: ToSciOptions) -> SciWrapper<'_, Self> { ... }
    fn to_sci(&self) -> SciWrapper<'_, Self> { ... }
}
Expand description

Converts a number to a string, possibly in scientific notation.

Required Methods§

source

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

Formats a number, possibly in scientific notation.

source

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether some formatting options can be applied to a number.

Provided Methods§

source

fn to_sci_with_options(&self, options: ToSciOptions) -> SciWrapper<'_, Self>

Converts a number to a string, possibly in scientific notation.

source

fn to_sci(&self) -> SciWrapper<'_, Self>

Converts a number to a string, possibly in scientific notation, using the default ToSciOptions.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl ToSci for i8

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for i16

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for i32

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for i64

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for i128

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for isize

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether a signed number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts a signed number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for u8

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for u16

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for u32

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for u64

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for u128

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

source§

impl ToSci for usize

source§

fn fmt_sci_valid(&self, options: ToSciOptions) -> bool

Determines whether an unsigned number can be converted to a string using to_sci_with_options and a particular set of options.

§Worst-case complexity

Constant time and additional memory.

§Examples

See here.

source§

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

Converts an unsigned number to a string using a specified base, possibly formatting the number using scientific notation.

See ToSciOptions for details on the available options. Note that setting neg_exp_threshold has no effect, since there is never a need to use negative exponents when representing an integer.

§Worst-case complexity

$T(n) = O(n)$

$M(n) = O(n)$

where $T$ is time, $M$ is additional memory, and $n$ is self.significant_bits().

§Panics

Panics if options.rounding_mode is Exact, but the size options are such that the input must be rounded.

§Examples

See here.

Implementors§