File tree 3 files changed +4
-6
lines changed
3 files changed +4
-6
lines changed Original file line number Diff line number Diff line change @@ -9,3 +9,4 @@ license = "MIT"
9
9
10
10
[dependencies ]
11
11
itoa = " 0.1"
12
+ ftoa = " 0.1"
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ use std::num::FpCategory;
3
3
use JsonValue ;
4
4
5
5
extern crate itoa;
6
+ extern crate ftoa;
6
7
7
8
const QU : u8 = b'"' ;
8
9
const BS : u8 = b'\\' ;
@@ -100,12 +101,7 @@ pub trait Generator {
100
101
if num. fract ( ) == 0.0 && num. abs ( ) < 1e19 {
101
102
itoa:: write ( self . get_writer ( ) , num as i64 ) . unwrap ( ) ;
102
103
} else {
103
- let abs = num. abs ( ) ;
104
- if abs < 1e-15 || abs > 1e19 {
105
- write ! ( self . get_writer( ) , "{:e}" , num) . unwrap ( ) ;
106
- } else {
107
- write ! ( self . get_writer( ) , "{}" , num) . unwrap ( ) ;
108
- }
104
+ ftoa:: write ( self . get_writer ( ) , num) . unwrap ( ) ;
109
105
}
110
106
} ,
111
107
FpCategory :: Zero => {
Original file line number Diff line number Diff line change @@ -204,6 +204,7 @@ mod codegen;
204
204
mod parser;
205
205
mod value;
206
206
mod error;
207
+
207
208
pub mod short;
208
209
pub mod object;
209
210
You can’t perform that action at this time.
0 commit comments