Skip to content

Commit faac32e

Browse files
committed
No DEC64 or analog, use a fork of dtoa to print out floats.
1 parent 006a50b commit faac32e

File tree

3 files changed

+4
-6
lines changed

3 files changed

+4
-6
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,4 @@ license = "MIT"
99

1010
[dependencies]
1111
itoa = "0.1"
12+
ftoa = "0.1"

src/codegen.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::num::FpCategory;
33
use JsonValue;
44

55
extern crate itoa;
6+
extern crate ftoa;
67

78
const QU: u8 = b'"';
89
const BS: u8 = b'\\';
@@ -100,12 +101,7 @@ pub trait Generator {
100101
if num.fract() == 0.0 && num.abs() < 1e19 {
101102
itoa::write(self.get_writer(), num as i64).unwrap();
102103
} 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();
109105
}
110106
},
111107
FpCategory::Zero => {

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ mod codegen;
204204
mod parser;
205205
mod value;
206206
mod error;
207+
207208
pub mod short;
208209
pub mod object;
209210

0 commit comments

Comments
 (0)