From ba594f24e19b6b142717eb2327388086b4c52756 Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Wed, 21 Aug 2019 13:30:49 +0200 Subject: [PATCH] document bug fix in release notes --- README.md | 5 +++++ RELEASES.md | 6 ++++++ src/display.rs | 10 ++++++++++ 3 files changed, 21 insertions(+) diff --git a/README.md b/README.md index ade7c10..1757ef1 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,11 @@ Various conversion methods are available: ## What’s new +### Version 0.4.4 news (unreleased) + + * Bug fix: rounding could produce bad output for [`Binary`], + [`Octal`], [`LowerHex`] and [`UpperHex`]. + ### Version 0.4.3 news (2019-08-20) * The [*fixed* crate] now requires rustc version 1.34.0 or later. diff --git a/RELEASES.md b/RELEASES.md index ceacc42..d9583a6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5,6 +5,12 @@ modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty. --> +Version 0.4.4 (unreleased) +========================== + + * Bug fix: rounding could produce bad output for `Binary`, `Octal`, + `LowerHex` and `UpperHex`. + Version 0.4.3 (2019-08-20) ========================== diff --git a/src/display.rs b/src/display.rs index 258de60..0c9e369 100644 --- a/src/display.rs +++ b/src/display.rs @@ -657,5 +657,15 @@ mod tests { assert_eq!(format!("{:.0o}", i), "376"); assert_eq!(format!("{:X}", i), "FE.8"); assert_eq!(format!("{:.0X}", i), "FE"); + + let i = U8F8::from_bits(0xFFDD); + assert_eq!(format!("{}", i), "254.863"); + assert_eq!(format!("{:.1}", i), "254.9"); + assert_eq!(format!("{:b}", i), "11111111.11011101"); + assert_eq!(format!("{:.4b}", i), "11111111.1110"); + assert_eq!(format!("{:o}", i), "375.672"); + assert_eq!(format!("{:.1o}", i), "375.7"); + assert_eq!(format!("{:X}", i), "FF.DD"); + assert_eq!(format!("{:.1X}", i), "FF.E"); } }