File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ use collections::Collection;
1919use iter:: { Iterator , range} ;
2020use kinds:: Copy ;
2121use mem;
22+ use num:: Float ;
2223use option:: { Option , Some , None } ;
2324use ops:: Deref ;
2425use result:: { Ok , Err } ;
@@ -584,7 +585,7 @@ macro_rules! floating(($ty:ident) => {
584585 float:: ExpNone ,
585586 false ,
586587 |bytes| {
587- fmt. pad_integral( * self >= 0.0 , "" , bytes)
588+ fmt. pad_integral( self . is_nan ( ) || * self >= 0.0 , "" , bytes)
588589 } )
589590 }
590591 }
@@ -605,7 +606,7 @@ macro_rules! floating(($ty:ident) => {
605606 float:: ExpDec ,
606607 false ,
607608 |bytes| {
608- fmt. pad_integral( * self >= 0.0 , "" , bytes)
609+ fmt. pad_integral( self . is_nan ( ) || * self >= 0.0 , "" , bytes)
609610 } )
610611 }
611612 }
@@ -626,7 +627,7 @@ macro_rules! floating(($ty:ident) => {
626627 float:: ExpDec ,
627628 true ,
628629 |bytes| {
629- fmt. pad_integral( * self >= 0.0 , "" , bytes)
630+ fmt. pad_integral( self . is_nan ( ) || * self >= 0.0 , "" , bytes)
630631 } )
631632 }
632633 }
Original file line number Diff line number Diff line change 1+ // Copyright 2014 The Rust Project Developers. See the COPYRIGHT
2+ // file at the top-level directory of this distribution and at
3+ // http://rust-lang.org/COPYRIGHT.
4+ //
5+ // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+ // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+ // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+ // option. This file may not be copied, modified, or distributed
9+ // except according to those terms.
10+
11+ pub fn main ( ) {
12+ use std:: f64;
13+ let x = "NaN" . to_string ( ) ;
14+ assert_eq ! ( format!( "{}" , f64 :: NAN ) , x) ;
15+ assert_eq ! ( format!( "{:e}" , f64 :: NAN ) , x) ;
16+ assert_eq ! ( format!( "{:E}" , f64 :: NAN ) , x) ;
17+ }
18+
You can’t perform that action at this time.
0 commit comments