Skip to content

Commit

Permalink
Merge #81
Browse files Browse the repository at this point in the history
81: Directly serialize f32 r=torkleyy a=pyfisch

Currently f32 is serialized by converting to f64 first. [This results in some numbers printed with many decimal places that do not convey information](https://play.rust-lang.org/?gist=2d8e4ab9d5d8fe689fdb6490bb4721c5&version=stable). (A f32 can represent about 6 decimal places)
  • Loading branch information
bors[bot] committed Jan 21, 2018
2 parents 52baba7 + 1261e65 commit d19c857
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,8 @@ impl<'a> ser::Serializer for &'a mut Serializer {
}

fn serialize_f32(self, v: f32) -> Result<()> {
self.serialize_f64(v as f64)
self.output += &v.to_string();
Ok(())
}

fn serialize_f64(self, v: f64) -> Result<()> {
Expand Down

0 comments on commit d19c857

Please sign in to comment.