File tree 2 files changed +22
-3
lines changed
2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ use collections::Collection;
19
19
use iter:: { Iterator , range} ;
20
20
use kinds:: Copy ;
21
21
use mem;
22
+ use num:: Float ;
22
23
use option:: { Option , Some , None } ;
23
24
use ops:: Deref ;
24
25
use result:: { Ok , Err } ;
@@ -584,7 +585,7 @@ macro_rules! floating(($ty:ident) => {
584
585
float:: ExpNone ,
585
586
false ,
586
587
|bytes| {
587
- fmt. pad_integral( * self >= 0.0 , "" , bytes)
588
+ fmt. pad_integral( self . is_nan ( ) || * self >= 0.0 , "" , bytes)
588
589
} )
589
590
}
590
591
}
@@ -605,7 +606,7 @@ macro_rules! floating(($ty:ident) => {
605
606
float:: ExpDec ,
606
607
false ,
607
608
|bytes| {
608
- fmt. pad_integral( * self >= 0.0 , "" , bytes)
609
+ fmt. pad_integral( self . is_nan ( ) || * self >= 0.0 , "" , bytes)
609
610
} )
610
611
}
611
612
}
@@ -626,7 +627,7 @@ macro_rules! floating(($ty:ident) => {
626
627
float:: ExpDec ,
627
628
true ,
628
629
|bytes| {
629
- fmt. pad_integral( * self >= 0.0 , "" , bytes)
630
+ fmt. pad_integral( self . is_nan ( ) || * self >= 0.0 , "" , bytes)
630
631
} )
631
632
}
632
633
}
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