Skip to content

Commit

Permalink
Auto merge of rust-lang#102935 - ajtribick:display-float-0.5-fixed-0,…
Browse files Browse the repository at this point in the history
… r=scottmcm

Fix inconsistent rounding of 0.5 when formatted to 0 decimal places

As described in rust-lang#70336, when displaying values to zero decimal places the value of 0.5 is rounded to 1, which is inconsistent with the display of other half-integer values which round to even.

From testing the flt2dec implementation, it looks like this comes down to the condition in the fixed-width Dragon implementation where an empty buffer is treated as a case to apply rounding up. I believe the change below fixes it and updates only the relevant tests.

Nevertheless I am aware this is very much a core piece of functionality, so please take a very careful look to make sure I haven't missed anything. I hope this change does not break anything in the wider ecosystem as having a consistent rounding behaviour in floating point formatting is in my opinion a useful feature to have.

Resolves rust-lang#70336
  • Loading branch information
bors committed Nov 16, 2022
2 parents af95f61 + 3fa89d0 commit cb95524
Showing 0 changed files with 0 additions and 0 deletions.

0 comments on commit cb95524

Please sign in to comment.