Skip to content

Commit e003ff4

Browse files
committed
use standard library for float from_str_radix with radix 10
1 parent e8da6fe commit e003ff4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/lib.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -224,6 +224,13 @@ macro_rules! float_trait_impl {
224224
use self::FloatErrorKind::*;
225225
use self::ParseFloatError as PFE;
226226

227+
// Special case radix 10 to use more accurate standard library implementation
228+
if radix == 10 {
229+
return src.parse().map_err(|_| PFE {
230+
kind: if src.is_empty() { Empty } else { Invalid },
231+
});
232+
}
233+
227234
// Special values
228235
match src {
229236
"inf" => return Ok(core::$t::INFINITY),

0 commit comments

Comments
 (0)