We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 870a260 commit 363b650Copy full SHA for 363b650
core/src/num/flt2dec/mod.rs
@@ -150,23 +150,19 @@ pub fn round_up(d: &mut [u8]) -> Option<u8> {
150
Some(i) => {
151
// d[i+1..n] is all nines
152
d[i] += 1;
153
- for j in i + 1..d.len() {
154
- d[j] = b'0';
155
- }
+ d[i + 1..].fill(b'0');
156
None
157
}
158
- None if d.len() > 0 => {
+ None if d.is_empty() => {
+ // an empty buffer rounds up (a bit strange but reasonable)
+ Some(b'1')
159
+ }
160
+ None => {
161
// 999..999 rounds to 1000..000 with an increased exponent
162
d[0] = b'1';
- for j in 1..d.len() {
163
+ d[1..].fill(b'0');
164
Some(b'0')
165
166
- None => {
167
- // an empty buffer rounds up (a bit strange but reasonable)
168
- Some(b'1')
169
170
171
172
0 commit comments