]> git.proxmox.com Git - rustc.git/blob - src/libcompiler_builtins/libm/src/math/ceilf.rs
New upstream version 1.29.0+dfsg1
[rustc.git] / src / libcompiler_builtins / libm / src / math / ceilf.rs
1 use core::f32;
2
3 #[inline]
4 pub fn ceilf(x: f32) -> f32 {
5 let mut ui = x.to_bits();
6 let e = (((ui >> 23) & 0xff) - 0x7f) as i32;
7
8 if e >= 23 {
9 return x;
10 }
11 if e >= 0 {
12 let m = 0x007fffff >> e;
13 if (ui & m) == 0 {
14 return x;
15 }
16 force_eval!(x + f32::from_bits(0x7b800000));
17 if ui >> 31 == 0 {
18 ui += m;
19 }
20 ui &= !m;
21 } else {
22 force_eval!(x + f32::from_bits(0x7b800000));
23 if ui >> 31 != 0 {
24 return -0.0;
25 } else if ui << 1 != 0 {
26 return 1.0;
27 }
28 }
29 return f32::from_bits(ui);
30 }