Function std::num::strconv::float_to_str_bytes_commonExperimental
[-]
[+]
[src]
pub fn float_to_str_bytes_common<T: Float>(num: T, radix: uint, negative_zero: bool, sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_upper: bool) -> (Vec<u8>, bool)
Converts a number to its string representation as a byte vector.
This is meant to be a common base implementation for all numeric string
conversion functions like to_string() or to_str_radix().
Arguments
num- The number to convert. Accepts any number that implements the numeric traits.radix- Base to use. Accepts only the values 2-36. If the exponential notation is used, then this base is only used for the significand. The exponent itself always printed using a base of 10.negative_zero- Whether to treat the special value-0as-0or as+0.sign- How to emit the sign. SeeSignFormat.digits- The amount of digits to use for emitting the fractional part, if any. SeeSignificantDigits.exp_format- Whether or not to use the exponential (scientific) notation. SeeExponentFormat.exp_capital- Whether or not to use a capital letter for the exponent sign, if exponential notation is desired.
Return value
A tuple containing the byte vector, and a boolean flag indicating
whether it represents a special value like inf, -inf, NaN or not.
It returns a tuple because there can be ambiguity between a special value
and a number representation at higher bases.
Panics
- Panics if
radix< 2 orradix> 36. - Panics if
radix> 14 andexp_formatisExpDecdue to conflict between digit and exponent sign'e'. - Panics if
radix> 25 andexp_formatisExpBindue to conflict between digit and exponent sign'p'.