]> git.lizzy.rs Git - rust.git/commit
Auto merge of #24269 - benashford:formatting-fix, r=alexcrichton
authorbors <bors@rust-lang.org>
Sat, 11 Apr 2015 15:34:24 +0000 (15:34 +0000)
committerbors <bors@rust-lang.org>
Sat, 11 Apr 2015 15:34:24 +0000 (15:34 +0000)
commit67a8f61730418768f07d8ed0f9735a31d0c5d84d
tree766fd249b394c2a1befc63b6da02e0e306ad9b23
parentacb3e5136c3ca0a0d27150136fa7ffecbee75b92
parentfaef52a847acc0dfe1e15117fe3201731209a95d
Auto merge of #24269 - benashford:formatting-fix, r=alexcrichton

This fixes the bug described in issue #23150.  This affected formatting any floating point number into a string in a formatting pattern that: a) required rounding up, and b) required an extra digit on the front.

So `format!("{:.0}", 9.9)` would fail, but `format!("{:.0}", 8.9)` would succeed.  This was due to a negative integer being cast to a `usize` resulting in an 'arithmetic operation overflowed' panic.

The fix was to change the order of operations so that the number is zero before casting.