Skip to content

Fixing #18659 #18713

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from Nov 7, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/libstd/num/strconv.rs
Original file line number Diff line number Diff line change
@@ -451,7 +451,7 @@ pub fn from_str_radix_float<T: Float>(src: &str, radix: uint) -> Option<T> {
};

// The significand to accumulate
let mut sig = if is_positive { _0 } else { -_1 };
let mut sig = if is_positive { _0 } else { -_0 };
// Necessary to detect overflow
let mut prev_sig = sig;
let mut cs = src.chars().enumerate();
@@ -647,6 +647,22 @@ mod test {
let fe : Option<f32> = from_str_radix_float("1e40", 10);
assert_eq!(fe, Some(Float::infinity()))
}

#[test]
fn test_from_str_radix_float() {
let x1 : Option<f64> = from_str_radix_float("-123.456", 10);
assert_eq!(x1, Some(-123.456));
let x2 : Option<f32> = from_str_radix_float("123.456", 10);
assert_eq!(x2, Some(123.456));
let x3 : Option<f32> = from_str_radix_float("-0.0", 10);
assert_eq!(x3, Some(-0.0));
let x4 : Option<f32> = from_str_radix_float("0.0", 10);
assert_eq!(x4, Some(0.0));
let x4 : Option<f32> = from_str_radix_float("1.0", 10);
assert_eq!(x4, Some(1.0));
let x5 : Option<f32> = from_str_radix_float("-1.0", 10);
assert_eq!(x5, Some(-1.0));
}
}

#[cfg(test)]