Skip to content

Commit 4534005

Browse files
committed
Fix overflow bug in f16::div_ceil
1 parent 3deff84 commit 4534005

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

library/std/src/f16/div_euclid.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ fn div_ceil(exp: i16, a: u16, b: u16) -> f16 {
6868
let aa = u32::from(a) << exp;
6969
let bb = u32::from(b);
7070
// q <= (2^27 - 2^16) / 2^10 + 1 = 2^17 - 2^6 + 1
71-
let q = ((aa - 1) / bb) as u16 + 1;
71+
let q = (aa - 1) / bb + 1;
7272
q as f16
7373
} else {
7474
// exp >= 17

0 commit comments

Comments
 (0)