diff --git a/src/libcore/num/flt2dec/mod.rs b/src/libcore/num/flt2dec/mod.rs index 8b4b3a45e9b33..74b190085b3d3 100644 --- a/src/libcore/num/flt2dec/mod.rs +++ b/src/libcore/num/flt2dec/mod.rs @@ -396,10 +396,10 @@ fn determine_sign(sign: Sign, decoded: &FullDecoded, negative: bool) -> &'static /// Formats given floating point number into the decimal form with at least /// given number of fractional digits. The result is stored to the supplied parts -/// array while utilizing given byte buffer as a scratch. `upper` is only used to -/// determine the case of non-finite values, i.e. `inf` and `nan`. The first part -/// to be rendered is always a `Part::Sign` (which can be an empty string -/// if no sign is rendered). +/// array while utilizing given byte buffer as a scratch. `upper` is currently +/// unused but left for the future decision to change the case of non-finite values, +/// i.e. `inf` and `nan`. The first part to be rendered is always a `Part::Sign` +/// (which can be an empty string if no sign is rendered). /// /// `format_shortest` should be the underlying digit-generation function. /// You probably would want `strategy::grisu::format_shortest` for this. @@ -413,7 +413,7 @@ fn determine_sign(sign: Sign, decoded: &FullDecoded, negative: bool) -> &'static /// There should be at least 5 parts available, due to the worst case like /// `[+][0.][0000][45][0000]` with `frac_digits = 10`. pub fn to_shortest_str<'a, T, F>(mut format_shortest: F, v: T, - sign: Sign, frac_digits: usize, upper: bool, + sign: Sign, frac_digits: usize, _upper: bool, buf: &'a mut [u8], parts: &'a mut [Part<'a>]) -> Formatted<'a> where T: DecodableFloat, F: FnMut(&Decoded, &mut [u8]) -> (usize, i16) { assert!(parts.len() >= 4); @@ -423,11 +423,11 @@ pub fn to_shortest_str<'a, T, F>(mut format_shortest: F, v: T, let sign = determine_sign(sign, &full_decoded, negative); match full_decoded { FullDecoded::Nan => { - parts[0] = Part::Copy(if upper { b"NAN" } else { b"nan" }); + parts[0] = Part::Copy(b"NaN"); Formatted { sign: sign, parts: &parts[..1] } } FullDecoded::Infinite => { - parts[0] = Part::Copy(if upper { b"INF" } else { b"inf" }); + parts[0] = Part::Copy(b"inf"); Formatted { sign: sign, parts: &parts[..1] } } FullDecoded::Zero => { @@ -479,11 +479,11 @@ pub fn to_shortest_exp_str<'a, T, F>(mut format_shortest: F, v: T, let sign = determine_sign(sign, &full_decoded, negative); match full_decoded { FullDecoded::Nan => { - parts[0] = Part::Copy(if upper { b"NAN" } else { b"nan" }); + parts[0] = Part::Copy(b"NaN"); Formatted { sign: sign, parts: &parts[..1] } } FullDecoded::Infinite => { - parts[0] = Part::Copy(if upper { b"INF" } else { b"inf" }); + parts[0] = Part::Copy(b"inf"); Formatted { sign: sign, parts: &parts[..1] } } FullDecoded::Zero => { @@ -557,11 +557,11 @@ pub fn to_exact_exp_str<'a, T, F>(mut format_exact: F, v: T, let sign = determine_sign(sign, &full_decoded, negative); match full_decoded { FullDecoded::Nan => { - parts[0] = Part::Copy(if upper { b"NAN" } else { b"nan" }); + parts[0] = Part::Copy(b"NaN"); Formatted { sign: sign, parts: &parts[..1] } } FullDecoded::Infinite => { - parts[0] = Part::Copy(if upper { b"INF" } else { b"inf" }); + parts[0] = Part::Copy(b"inf"); Formatted { sign: sign, parts: &parts[..1] } } FullDecoded::Zero => { @@ -589,10 +589,10 @@ pub fn to_exact_exp_str<'a, T, F>(mut format_exact: F, v: T, /// Formats given floating point number into the decimal form with exactly /// given number of fractional digits. The result is stored to the supplied parts -/// array while utilizing given byte buffer as a scratch. `upper` is only used to -/// determine the case of non-finite values, i.e. `inf` and `nan`. The first part -/// to be rendered is always a `Part::Sign` (which can be an empty string -/// if no sign is rendered). +/// array while utilizing given byte buffer as a scratch. `upper` is currently +/// unused but left for the future decision to change the case of non-finite values, +/// i.e. `inf` and `nan`. The first part to be rendered is always a `Part::Sign` +/// (which can be an empty string if no sign is rendered). /// /// `format_exact` should be the underlying digit-generation function. /// You probably would want `strategy::grisu::format_exact` for this. @@ -603,7 +603,7 @@ pub fn to_exact_exp_str<'a, T, F>(mut format_exact: F, v: T, /// There should be at least 5 parts available, due to the worst case like /// `[+][0.][0000][45][0000]` with `frac_digits = 10`. pub fn to_exact_fixed_str<'a, T, F>(mut format_exact: F, v: T, - sign: Sign, frac_digits: usize, upper: bool, + sign: Sign, frac_digits: usize, _upper: bool, buf: &'a mut [u8], parts: &'a mut [Part<'a>]) -> Formatted<'a> where T: DecodableFloat, F: FnMut(&Decoded, &mut [u8], i16) -> (usize, i16) { assert!(parts.len() >= 4); @@ -612,11 +612,11 @@ pub fn to_exact_fixed_str<'a, T, F>(mut format_exact: F, v: T, let sign = determine_sign(sign, &full_decoded, negative); match full_decoded { FullDecoded::Nan => { - parts[0] = Part::Copy(if upper { b"NAN" } else { b"nan" }); + parts[0] = Part::Copy(b"NaN"); Formatted { sign: sign, parts: &parts[..1] } } FullDecoded::Infinite => { - parts[0] = Part::Copy(if upper { b"INF" } else { b"inf" }); + parts[0] = Part::Copy(b"inf"); Formatted { sign: sign, parts: &parts[..1] } } FullDecoded::Zero => { diff --git a/src/libcoretest/num/flt2dec/mod.rs b/src/libcoretest/num/flt2dec/mod.rs index 07880b22ce5a8..3ffec7c007e5f 100644 --- a/src/libcoretest/num/flt2dec/mod.rs +++ b/src/libcoretest/num/flt2dec/mod.rs @@ -544,17 +544,17 @@ pub fn to_shortest_str_test(mut f_: F) assert_eq!(to_string(f, -0.0, MinusPlusRaw, 8, true), "-0.00000000"); assert_eq!(to_string(f, 1.0/0.0, Minus, 0, false), "inf"); - assert_eq!(to_string(f, 1.0/0.0, MinusRaw, 0, true), "INF"); + assert_eq!(to_string(f, 1.0/0.0, MinusRaw, 0, true), "inf"); assert_eq!(to_string(f, 1.0/0.0, MinusPlus, 0, false), "+inf"); - assert_eq!(to_string(f, 1.0/0.0, MinusPlusRaw, 0, true), "+INF"); - assert_eq!(to_string(f, 0.0/0.0, Minus, 0, false), "nan"); - assert_eq!(to_string(f, 0.0/0.0, MinusRaw, 1, true), "NAN"); - assert_eq!(to_string(f, 0.0/0.0, MinusPlus, 8, false), "nan"); - assert_eq!(to_string(f, 0.0/0.0, MinusPlusRaw, 64, true), "NAN"); + assert_eq!(to_string(f, 1.0/0.0, MinusPlusRaw, 0, true), "+inf"); + assert_eq!(to_string(f, 0.0/0.0, Minus, 0, false), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusRaw, 1, true), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusPlus, 8, false), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusPlusRaw, 64, true), "NaN"); assert_eq!(to_string(f, -1.0/0.0, Minus, 0, false), "-inf"); - assert_eq!(to_string(f, -1.0/0.0, MinusRaw, 1, true), "-INF"); + assert_eq!(to_string(f, -1.0/0.0, MinusRaw, 1, true), "-inf"); assert_eq!(to_string(f, -1.0/0.0, MinusPlus, 8, false), "-inf"); - assert_eq!(to_string(f, -1.0/0.0, MinusPlusRaw, 64, true), "-INF"); + assert_eq!(to_string(f, -1.0/0.0, MinusPlusRaw, 64, true), "-inf"); assert_eq!(to_string(f, 3.14, Minus, 0, false), "3.14"); assert_eq!(to_string(f, 3.14, MinusRaw, 0, false), "3.14"); @@ -638,17 +638,17 @@ pub fn to_shortest_exp_str_test(mut f_: F) assert_eq!(to_string(f, -0.0, MinusPlusRaw, ( 5, 9), false), "-0e0"); assert_eq!(to_string(f, 1.0/0.0, Minus, (-4, 16), false), "inf"); - assert_eq!(to_string(f, 1.0/0.0, MinusRaw, (-4, 16), true), "INF"); + assert_eq!(to_string(f, 1.0/0.0, MinusRaw, (-4, 16), true), "inf"); assert_eq!(to_string(f, 1.0/0.0, MinusPlus, (-4, 16), false), "+inf"); - assert_eq!(to_string(f, 1.0/0.0, MinusPlusRaw, (-4, 16), true), "+INF"); - assert_eq!(to_string(f, 0.0/0.0, Minus, ( 0, 0), false), "nan"); - assert_eq!(to_string(f, 0.0/0.0, MinusRaw, ( 0, 0), true), "NAN"); - assert_eq!(to_string(f, 0.0/0.0, MinusPlus, (-9, -5), false), "nan"); - assert_eq!(to_string(f, 0.0/0.0, MinusPlusRaw, ( 5, 9), true), "NAN"); + assert_eq!(to_string(f, 1.0/0.0, MinusPlusRaw, (-4, 16), true), "+inf"); + assert_eq!(to_string(f, 0.0/0.0, Minus, ( 0, 0), false), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusRaw, ( 0, 0), true), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusPlus, (-9, -5), false), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusPlusRaw, ( 5, 9), true), "NaN"); assert_eq!(to_string(f, -1.0/0.0, Minus, ( 0, 0), false), "-inf"); - assert_eq!(to_string(f, -1.0/0.0, MinusRaw, ( 0, 0), true), "-INF"); + assert_eq!(to_string(f, -1.0/0.0, MinusRaw, ( 0, 0), true), "-inf"); assert_eq!(to_string(f, -1.0/0.0, MinusPlus, (-9, -5), false), "-inf"); - assert_eq!(to_string(f, -1.0/0.0, MinusPlusRaw, ( 5, 9), true), "-INF"); + assert_eq!(to_string(f, -1.0/0.0, MinusPlusRaw, ( 5, 9), true), "-inf"); assert_eq!(to_string(f, 3.14, Minus, (-4, 16), false), "3.14"); assert_eq!(to_string(f, 3.14, MinusRaw, (-4, 16), false), "3.14"); @@ -752,17 +752,17 @@ pub fn to_exact_exp_str_test(mut f_: F) assert_eq!(to_string(f, -0.0, MinusPlusRaw, 8, false), "-0.0000000e0"); assert_eq!(to_string(f, 1.0/0.0, Minus, 1, false), "inf"); - assert_eq!(to_string(f, 1.0/0.0, MinusRaw, 1, true), "INF"); + assert_eq!(to_string(f, 1.0/0.0, MinusRaw, 1, true), "inf"); assert_eq!(to_string(f, 1.0/0.0, MinusPlus, 1, false), "+inf"); - assert_eq!(to_string(f, 1.0/0.0, MinusPlusRaw, 1, true), "+INF"); - assert_eq!(to_string(f, 0.0/0.0, Minus, 8, false), "nan"); - assert_eq!(to_string(f, 0.0/0.0, MinusRaw, 8, true), "NAN"); - assert_eq!(to_string(f, 0.0/0.0, MinusPlus, 8, false), "nan"); - assert_eq!(to_string(f, 0.0/0.0, MinusPlusRaw, 8, true), "NAN"); + assert_eq!(to_string(f, 1.0/0.0, MinusPlusRaw, 1, true), "+inf"); + assert_eq!(to_string(f, 0.0/0.0, Minus, 8, false), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusRaw, 8, true), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusPlus, 8, false), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusPlusRaw, 8, true), "NaN"); assert_eq!(to_string(f, -1.0/0.0, Minus, 64, false), "-inf"); - assert_eq!(to_string(f, -1.0/0.0, MinusRaw, 64, true), "-INF"); + assert_eq!(to_string(f, -1.0/0.0, MinusRaw, 64, true), "-inf"); assert_eq!(to_string(f, -1.0/0.0, MinusPlus, 64, false), "-inf"); - assert_eq!(to_string(f, -1.0/0.0, MinusPlusRaw, 64, true), "-INF"); + assert_eq!(to_string(f, -1.0/0.0, MinusPlusRaw, 64, true), "-inf"); assert_eq!(to_string(f, 3.14, Minus, 1, true), "3E0"); assert_eq!(to_string(f, 3.14, MinusRaw, 1, false), "3e0"); @@ -973,17 +973,17 @@ pub fn to_exact_fixed_str_test(mut f_: F) assert_eq!(to_string(f, -0.0, MinusPlusRaw, 8, true), "-0.00000000"); assert_eq!(to_string(f, 1.0/0.0, Minus, 0, false), "inf"); - assert_eq!(to_string(f, 1.0/0.0, MinusRaw, 1, true), "INF"); + assert_eq!(to_string(f, 1.0/0.0, MinusRaw, 1, true), "inf"); assert_eq!(to_string(f, 1.0/0.0, MinusPlus, 8, false), "+inf"); - assert_eq!(to_string(f, 1.0/0.0, MinusPlusRaw, 64, true), "+INF"); - assert_eq!(to_string(f, 0.0/0.0, Minus, 0, false), "nan"); - assert_eq!(to_string(f, 0.0/0.0, MinusRaw, 1, true), "NAN"); - assert_eq!(to_string(f, 0.0/0.0, MinusPlus, 8, false), "nan"); - assert_eq!(to_string(f, 0.0/0.0, MinusPlusRaw, 64, true), "NAN"); + assert_eq!(to_string(f, 1.0/0.0, MinusPlusRaw, 64, true), "+inf"); + assert_eq!(to_string(f, 0.0/0.0, Minus, 0, false), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusRaw, 1, true), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusPlus, 8, false), "NaN"); + assert_eq!(to_string(f, 0.0/0.0, MinusPlusRaw, 64, true), "NaN"); assert_eq!(to_string(f, -1.0/0.0, Minus, 0, false), "-inf"); - assert_eq!(to_string(f, -1.0/0.0, MinusRaw, 1, true), "-INF"); + assert_eq!(to_string(f, -1.0/0.0, MinusRaw, 1, true), "-inf"); assert_eq!(to_string(f, -1.0/0.0, MinusPlus, 8, false), "-inf"); - assert_eq!(to_string(f, -1.0/0.0, MinusPlusRaw, 64, true), "-INF"); + assert_eq!(to_string(f, -1.0/0.0, MinusPlusRaw, 64, true), "-inf"); assert_eq!(to_string(f, 3.14, Minus, 0, false), "3"); assert_eq!(to_string(f, 3.14, MinusRaw, 0, false), "3");