]> git.proxmox.com Git - rustc.git/blobdiff - src/librustc_const_math/float.rs
New upstream version 1.23.0+dfsg1
[rustc.git] / src / librustc_const_math / float.rs
index b67048939e43eb1592bc6c378aeeb02634b207a2..9d820ea8cbed2990e91ab163aee9416840f8e8b1 100644 (file)
@@ -203,3 +203,11 @@ impl ::std::ops::Neg for ConstFloat {
         ConstFloat { bits, ty: self.ty }
     }
 }
+
+/// This is `f32::MAX + (0.5 ULP)` as an integer. Numbers greater or equal to this
+/// are rounded to infinity when converted to `f32`.
+///
+/// NB: Computed as maximum significand with an extra 1 bit added (for the half ULP)
+/// shifted by the maximum exponent (accounting for normalization).
+pub const MAX_F32_PLUS_HALF_ULP: u128 = ((1 << (Single::PRECISION + 1)) - 1)
+                                        << (Single::MAX_EXP - Single::PRECISION as i16);