add ceil and floor
[vector-math.git] / src / prim.rs
index 4b3c6ca66f8584adf3e4ed98fb234d0583b2b3e3..ea7b6b94010b7bf78da9a1873dd8b158340d1285 100644 (file)
@@ -163,6 +163,8 @@ pub trait PrimFloat:
     fn trunc(self) -> Self;
     /// round to nearest, ties to unspecified
     fn round(self) -> Self;
+    fn floor(self) -> Self;
+    fn ceil(self) -> Self;
     fn copy_sign(self, sign: Self) -> Self;
 }
 
@@ -232,6 +234,18 @@ macro_rules! impl_float {
                 return crate::algorithms::base::round_to_nearest_ties_to_even(Scalar, Value(self))
                     .0;
             }
+            fn floor(self) -> Self {
+                #[cfg(feature = "std")]
+                return $float::floor(self);
+                #[cfg(not(feature = "std"))]
+                return crate::algorithms::base::floor(Scalar, Value(self)).0;
+            }
+            fn ceil(self) -> Self {
+                #[cfg(feature = "std")]
+                return $float::ceil(self);
+                #[cfg(not(feature = "std"))]
+                return crate::algorithms::base::ceil(Scalar, Value(self)).0;
+            }
             fn copy_sign(self, sign: Self) -> Self {
                 #[cfg(feature = "std")]
                 return $float::copysign(self, sign);