ExponentFormat
SignFormat
SignificantDigits
NumStrConv
of NumStrConv for float
of NumStrConv for f32
of NumStrConv for f64
of NumStrConv for int
of NumStrConv for i8
of NumStrConv for i16
of NumStrConv for i32
of NumStrConv for i64
of NumStrConv for uint
of NumStrConv for u8
of NumStrConv for u16
of NumStrConv for u32
of NumStrConv for u64
float_to_str_bytes_common
- Converts a number to its string representation as a byte vectorfloat_to_str_common
- Converts a number to its string representationfrom_str_bytes_common
- Parses a byte slice as a numberfrom_str_common
- Parses a string as a numberint_to_str_bytes_common
- Converts an integral number to its string representation as a byte vectorExponentFormat
ExpNone
ExpDec
ExpBin
SignFormat
SignNone
SignNeg
SignAll
SignificantDigits
DigAll
DigMax(uint)
DigExact(uint)
NumStrConv
NaN
fn NaN() -> Option<Self>
inf
fn inf() -> Option<Self>
neg_inf
fn neg_inf() -> Option<Self>
neg_zero
fn neg_zero() -> Option<Self>
round_to_zero
fn round_to_zero(&self) -> Self
fractional_part
fn fractional_part(&self) -> Self
NumStrConv
for float
NaN
fn NaN() -> Option<float>
inf
fn inf() -> Option<float>
neg_inf
fn neg_inf() -> Option<float>
neg_zero
fn neg_zero() -> Option<float>
round_to_zero
fn round_to_zero(&self) -> float
fractional_part
fn fractional_part(&self) -> float
NumStrConv
for f32
NaN
fn NaN() -> Option<f32>
inf
fn inf() -> Option<f32>
neg_inf
fn neg_inf() -> Option<f32>
neg_zero
fn neg_zero() -> Option<f32>
round_to_zero
fn round_to_zero(&self) -> f32
fractional_part
fn fractional_part(&self) -> f32
NumStrConv
for f64
NaN
fn NaN() -> Option<f64>
inf
fn inf() -> Option<f64>
neg_inf
fn neg_inf() -> Option<f64>
neg_zero
fn neg_zero() -> Option<f64>
round_to_zero
fn round_to_zero(&self) -> f64
fractional_part
fn fractional_part(&self) -> f64
NumStrConv
for int
NaN
fn NaN() -> Option<int>
inf
fn inf() -> Option<int>
neg_inf
fn neg_inf() -> Option<int>
neg_zero
fn neg_zero() -> Option<int>
round_to_zero
fn round_to_zero(&self) -> int
fractional_part
fn fractional_part(&self) -> int
NumStrConv
for i8
NaN
fn NaN() -> Option<i8>
inf
fn inf() -> Option<i8>
neg_inf
fn neg_inf() -> Option<i8>
neg_zero
fn neg_zero() -> Option<i8>
round_to_zero
fn round_to_zero(&self) -> i8
fractional_part
fn fractional_part(&self) -> i8
NumStrConv
for i16
NaN
fn NaN() -> Option<i16>
inf
fn inf() -> Option<i16>
neg_inf
fn neg_inf() -> Option<i16>
neg_zero
fn neg_zero() -> Option<i16>
round_to_zero
fn round_to_zero(&self) -> i16
fractional_part
fn fractional_part(&self) -> i16
NumStrConv
for i32
NaN
fn NaN() -> Option<i32>
inf
fn inf() -> Option<i32>
neg_inf
fn neg_inf() -> Option<i32>
neg_zero
fn neg_zero() -> Option<i32>
round_to_zero
fn round_to_zero(&self) -> i32
fractional_part
fn fractional_part(&self) -> i32
NumStrConv
for i64
NaN
fn NaN() -> Option<i64>
inf
fn inf() -> Option<i64>
neg_inf
fn neg_inf() -> Option<i64>
neg_zero
fn neg_zero() -> Option<i64>
round_to_zero
fn round_to_zero(&self) -> i64
fractional_part
fn fractional_part(&self) -> i64
NumStrConv
for uint
NaN
fn NaN() -> Option<uint>
inf
fn inf() -> Option<uint>
neg_inf
fn neg_inf() -> Option<uint>
neg_zero
fn neg_zero() -> Option<uint>
round_to_zero
fn round_to_zero(&self) -> uint
fractional_part
fn fractional_part(&self) -> uint
NumStrConv
for u8
NaN
fn NaN() -> Option<u8>
inf
fn inf() -> Option<u8>
neg_inf
fn neg_inf() -> Option<u8>
neg_zero
fn neg_zero() -> Option<u8>
round_to_zero
fn round_to_zero(&self) -> u8
fractional_part
fn fractional_part(&self) -> u8
NumStrConv
for u16
NaN
fn NaN() -> Option<u16>
inf
fn inf() -> Option<u16>
neg_inf
fn neg_inf() -> Option<u16>
neg_zero
fn neg_zero() -> Option<u16>
round_to_zero
fn round_to_zero(&self) -> u16
fractional_part
fn fractional_part(&self) -> u16
NumStrConv
for u32
NaN
fn NaN() -> Option<u32>
inf
fn inf() -> Option<u32>
neg_inf
fn neg_inf() -> Option<u32>
neg_zero
fn neg_zero() -> Option<u32>
round_to_zero
fn round_to_zero(&self) -> u32
fractional_part
fn fractional_part(&self) -> u32
NumStrConv
for u64
NaN
fn NaN() -> Option<u64>
inf
fn inf() -> Option<u64>
neg_inf
fn neg_inf() -> Option<u64>
neg_zero
fn neg_zero() -> Option<u64>
round_to_zero
fn round_to_zero(&self) -> u64
fractional_part
fn fractional_part(&self) -> u64
float_to_str_bytes_common
fn float_to_str_bytes_common<T: NumCast + Zero + One + Eq + Ord + Float +
Round + Div<T, T> + Neg<T> + Rem<T, T> +
Mul<T,
T>>(num: T, radix: uint, negative_zero: bool,
sign: SignFormat,
digits: SignificantDigits) ->
(~[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_str()
or to_str_radix()
.
num
- The number to convert. Accepts any number that implements the numeric traits.radix
- Base to use. Accepts only the values 2-36.negative_zero
- Whether to treat the special value -0
as -0
or as +0
.sign
- How to emit the sign. Options are:
SignNone
: No sign at all. Basically emits abs(num)
.SignNeg
: Only -
on negative values.SignAll
: Both +
on positive, and -
on negative numbers.digits
- The amount of digits to use for emitting the fractional part, if any. Options are:
DigAll
: All calculatable digits. Beware of bignums or fractions!DigMax(uint)
: Maximum N digits, truncating any trailing zeros.DigExact(uint)
: Exactly N digits.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.
radix
< 2 or radix
> 36.float_to_str_common
fn float_to_str_common<T: NumCast + Zero + One + Eq + Ord + NumStrConv +
Float + Round + Div<T, T> + Neg<T> + Rem<T, T> +
Mul<T,
T>>(num: T, radix: uint, negative_zero: bool,
sign: SignFormat, digits: SignificantDigits) ->
(~str, bool)
Converts a number to its string representation. This is a wrapper for to_str_bytes_common()
, for details see there.
from_str_bytes_common
fn from_str_bytes_common<T: NumCast + Zero + One + Eq + Ord + Copy +
Div<T, T> + Mul<T, T> + Sub<T, T> + Neg<T> +
Add<T, T> +
NumStrConv>(buf: &[u8], radix: uint, negative: bool,
fractional: bool, special: bool,
exponent: ExponentFormat,
empty_zero: bool,
ignore_underscores: bool) -> Option<T>
Parses a byte slice as a number. This is meant to be a common base implementation for all numeric string conversion functions like from_str()
or from_str_radix()
.
buf
- The byte slice to parse.radix
- Which base to parse the number as. Accepts 2-36.negative
- Whether to accept negative numbers.fractional
- Whether to accept numbers with fractional parts.special
- Whether to accept special values like inf
and NaN
. Can conflict with radix
, see Failure.exponent
- Which exponent format to accept. Options are:
ExpNone
: No Exponent, accepts just plain numbers like 42
or -8.2
.ExpDec
: Accepts numbers with a decimal exponent like 42e5
or 8.2E-2
. The exponent string itself is always base 10. Can conflict with radix
, see Failure.ExpBin
: Accepts numbers with a binary exponent like 42P-8
or FFp128
. The exponent string itself is always base 10. Can conflict with radix
, see Failure.empty_zero
- Whether to accept a empty buf
as a 0 or not.ignore_underscores
- Whether all underscores within the string should be ignored.Returns Some(n)
if buf
parses to a number n without overflowing, and None
otherwise, depending on the constraints set by the remaining arguments.
radix
< 2 or radix
> 36.radix
> 14 and exponent
is ExpDec
due to conflict between digit and exponent sign 'e'
.radix
> 25 and exponent
is ExpBin
due to conflict between digit and exponent sign 'p'
.radix
> 18 and special == true
due to conflict between digit and lowest first character in inf
and NaN
, the 'i'
.from_str_common
fn from_str_common<T: NumCast + Zero + One + Eq + Ord + Copy + Div<T, T> +
Mul<T, T> + Sub<T, T> + Neg<T> + Add<T, T> +
NumStrConv>(buf: &str, radix: uint, negative: bool,
fractional: bool, special: bool,
exponent: ExponentFormat, empty_zero: bool,
ignore_underscores: bool) -> Option<T>
Parses a string as a number. This is a wrapper for from_str_bytes_common()
, for details see there.
int_to_str_bytes_common
fn int_to_str_bytes_common<T: NumCast + Zero + Eq + Ord + Integer +
Div<T, T> + Neg<T> + Rem<T, T> +
Mul<T,
T>>(num: T, radix: uint, sign: SignFormat,
f: &fn(u8))
Converts an integral number to its string representation as a byte vector. This is meant to be a common base implementation for all integral string conversion functions like to_str()
or to_str_radix()
.
num
- The number to convert. Accepts any number that implements the numeric traits.radix
- Base to use. Accepts only the values 2-36.sign
- How to emit the sign. Options are:
SignNone
: No sign at all. Basically emits abs(num)
.SignNeg
: Only -
on negative values.SignAll
: Both +
on positive, and -
on negative numbers.f
- a callback which will be invoked for each ascii character which composes the string representation of this integerA 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.
radix
< 2 or radix
> 36.