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 0f3948d commit a79da96Copy full SHA for a79da96
crates/spirv-std/src/math_ext.rs
@@ -11,6 +11,8 @@ pub trait MathExt {
11
fn ceil(self) -> Self;
12
fn exp(self) -> Self;
13
fn saturate(self) -> Self;
14
+ fn trunc(self) -> Self;
15
+ fn fract(self) -> Self;
16
17
fn signum(self) -> Self;
18
fn copysign(self, sign: Self) -> Self;
@@ -71,6 +73,14 @@ impl MathExt for f32 {
71
73
self.max(0.0).min(1.0)
72
74
}
75
76
+ fn trunc(self) -> f32 {
77
+ unsafe { core::intrinsics::truncf32(self) }
78
+ }
79
+
80
+ fn fract(self) -> f32 {
81
+ self - self.trunc()
82
83
84
fn signum(self) -> f32 {
85
if self.is_nan() {
86
Self::NAN
0 commit comments