diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-15 18:34:18 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-02-15 18:42:47 +0530 |
| commit | f7870b6faa43a9e63b5575d5d9663457003a8ac5 (patch) | |
| tree | d7cc47b3b9417d037b687c74678b1febf59d07df /src/libstd/num | |
| parent | 8acaaa9e0e631944ae809d3228561f7dfc44e66b (diff) | |
| parent | b1cd76906a4c7e40e3eb3569450d2dbd3be9fcab (diff) | |
| download | rust-f7870b6faa43a9e63b5575d5d9663457003a8ac5.tar.gz rust-f7870b6faa43a9e63b5575d5d9663457003a8ac5.zip | |
Rollup merge of #22339 - petrochenkov:int, r=huonw
Some function signatures have changed, so this is a [breaking-change]. In particular, radixes and numerical values of digits are represented by `u32` now. Part of #22240
Diffstat (limited to 'src/libstd/num')
| -rw-r--r-- | src/libstd/num/f32.rs | 14 | ||||
| -rw-r--r-- | src/libstd/num/f64.rs | 14 | ||||
| -rw-r--r-- | src/libstd/num/strconv.rs | 14 |
3 files changed, 21 insertions, 21 deletions
diff --git a/src/libstd/num/f32.rs b/src/libstd/num/f32.rs index 83a5c68912c..7d15a16309e 100644 --- a/src/libstd/num/f32.rs +++ b/src/libstd/num/f32.rs @@ -370,7 +370,7 @@ impl Float for f32 { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_string(num: f32) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigAll, ExpNone, false); + num, 10, true, SignNeg, DigAll, ExpNone, false); r } @@ -383,7 +383,7 @@ pub fn to_string(num: f32) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_hex(num: f32) -> String { let (r, _) = strconv::float_to_str_common( - num, 16u, true, SignNeg, DigAll, ExpNone, false); + num, 16, true, SignNeg, DigAll, ExpNone, false); r } @@ -396,7 +396,7 @@ pub fn to_str_hex(num: f32) -> String { /// * radix - The base to use #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) { +pub fn to_str_radix_special(num: f32, rdx: u32) -> (String, bool) { strconv::float_to_str_common(num, rdx, true, SignNeg, DigAll, ExpNone, false) } @@ -411,7 +411,7 @@ pub fn to_str_radix_special(num: f32, rdx: uint) -> (String, bool) { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exact(num: f32, dig: uint) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigExact(dig), ExpNone, false); + num, 10, true, SignNeg, DigExact(dig), ExpNone, false); r } @@ -426,7 +426,7 @@ pub fn to_str_exact(num: f32, dig: uint) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_digits(num: f32, dig: uint) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigMax(dig), ExpNone, false); + num, 10, true, SignNeg, DigMax(dig), ExpNone, false); r } @@ -442,7 +442,7 @@ pub fn to_str_digits(num: f32, dig: uint) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigExact(dig), ExpDec, upper); + num, 10, true, SignNeg, DigExact(dig), ExpDec, upper); r } @@ -458,7 +458,7 @@ pub fn to_str_exp_exact(num: f32, dig: uint, upper: bool) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exp_digits(num: f32, dig: uint, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigMax(dig), ExpDec, upper); + num, 10, true, SignNeg, DigMax(dig), ExpDec, upper); r } diff --git a/src/libstd/num/f64.rs b/src/libstd/num/f64.rs index f243955d199..0ce56371c77 100644 --- a/src/libstd/num/f64.rs +++ b/src/libstd/num/f64.rs @@ -379,7 +379,7 @@ impl Float for f64 { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_string(num: f64) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigAll, ExpNone, false); + num, 10, true, SignNeg, DigAll, ExpNone, false); r } @@ -392,7 +392,7 @@ pub fn to_string(num: f64) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_hex(num: f64) -> String { let (r, _) = strconv::float_to_str_common( - num, 16u, true, SignNeg, DigAll, ExpNone, false); + num, 16, true, SignNeg, DigAll, ExpNone, false); r } @@ -405,7 +405,7 @@ pub fn to_str_hex(num: f64) -> String { /// * radix - The base to use #[inline] #[unstable(feature = "std_misc", reason = "may be removed or relocated")] -pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) { +pub fn to_str_radix_special(num: f64, rdx: u32) -> (String, bool) { strconv::float_to_str_common(num, rdx, true, SignNeg, DigAll, ExpNone, false) } @@ -420,7 +420,7 @@ pub fn to_str_radix_special(num: f64, rdx: uint) -> (String, bool) { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exact(num: f64, dig: uint) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigExact(dig), ExpNone, false); + num, 10, true, SignNeg, DigExact(dig), ExpNone, false); r } @@ -435,7 +435,7 @@ pub fn to_str_exact(num: f64, dig: uint) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_digits(num: f64, dig: uint) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigMax(dig), ExpNone, false); + num, 10, true, SignNeg, DigMax(dig), ExpNone, false); r } @@ -451,7 +451,7 @@ pub fn to_str_digits(num: f64, dig: uint) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigExact(dig), ExpDec, upper); + num, 10, true, SignNeg, DigExact(dig), ExpDec, upper); r } @@ -467,7 +467,7 @@ pub fn to_str_exp_exact(num: f64, dig: uint, upper: bool) -> String { #[unstable(feature = "std_misc", reason = "may be removed or relocated")] pub fn to_str_exp_digits(num: f64, dig: uint, upper: bool) -> String { let (r, _) = strconv::float_to_str_common( - num, 10u, true, SignNeg, DigMax(dig), ExpDec, upper); + num, 10, true, SignNeg, DigMax(dig), ExpDec, upper); r } diff --git a/src/libstd/num/strconv.rs b/src/libstd/num/strconv.rs index 4ae7d3437fd..cf5e1eb0eb7 100644 --- a/src/libstd/num/strconv.rs +++ b/src/libstd/num/strconv.rs @@ -182,7 +182,7 @@ fn int_to_str_bytes_common<T, F>(num: T, radix: uint, sign: SignFormat, mut f: F /// - Panics if `radix` > 25 and `exp_format` is `ExpBin` due to conflict /// between digit and exponent sign `'p'`. pub fn float_to_str_bytes_common<T: Float>( - num: T, radix: uint, negative_zero: bool, + num: T, radix: u32, negative_zero: bool, sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_upper: bool ) -> (Vec<u8>, bool) { assert!(2 <= radix && radix <= 36); @@ -253,7 +253,7 @@ pub fn float_to_str_bytes_common<T: Float>( deccum = deccum / radix_gen; deccum = deccum.trunc(); - buf.push(char::from_digit(current_digit.to_int().unwrap() as uint, radix) + buf.push(char::from_digit(current_digit.to_int().unwrap() as u32, radix) .unwrap() as u8); // No more digits to calculate for the non-fractional part -> break @@ -310,7 +310,7 @@ pub fn float_to_str_bytes_common<T: Float>( let current_digit = deccum.trunc().abs(); buf.push(char::from_digit( - current_digit.to_int().unwrap() as uint, radix).unwrap() as u8); + current_digit.to_int().unwrap() as u32, radix).unwrap() as u8); // Decrease the deccumulator one fractional digit at a time deccum = deccum.fract(); @@ -324,7 +324,7 @@ pub fn float_to_str_bytes_common<T: Float>( let ascii2value = |chr: u8| { (chr as char).to_digit(radix).unwrap() }; - let value2ascii = |val: uint| { + let value2ascii = |val: u32| { char::from_digit(val, radix).unwrap() as u8 }; @@ -412,7 +412,7 @@ pub fn float_to_str_bytes_common<T: Float>( /// `to_str_bytes_common()`, for details see there. #[inline] pub fn float_to_str_common<T: Float>( - num: T, radix: uint, negative_zero: bool, + num: T, radix: u32, negative_zero: bool, sign: SignFormat, digits: SignificantDigits, exp_format: ExponentFormat, exp_capital: bool ) -> (String, bool) { let (bytes, special) = float_to_str_bytes_common(num, radix, @@ -422,8 +422,8 @@ pub fn float_to_str_common<T: Float>( // Some constants for from_str_bytes_common's input validation, // they define minimum radix values for which the character is a valid digit. -static DIGIT_P_RADIX: uint = ('p' as uint) - ('a' as uint) + 11u; -static DIGIT_E_RADIX: uint = ('e' as uint) - ('a' as uint) + 11u; +static DIGIT_P_RADIX: u32 = ('p' as u32) - ('a' as u32) + 11; +static DIGIT_E_RADIX: u32 = ('e' as u32) - ('a' as u32) + 11; #[cfg(test)] mod tests { |
