mirror of
https://github.com/EmbarkStudios/rust-gpu.git
synced 2024-11-25 08:14:12 +00:00
add trunc and fract to MathExt (#222)
This commit is contained in:
parent
0f3948dc27
commit
a79da96307
@ -11,6 +11,8 @@ pub trait MathExt {
|
||||
fn ceil(self) -> Self;
|
||||
fn exp(self) -> Self;
|
||||
fn saturate(self) -> Self;
|
||||
fn trunc(self) -> Self;
|
||||
fn fract(self) -> Self;
|
||||
|
||||
fn signum(self) -> Self;
|
||||
fn copysign(self, sign: Self) -> Self;
|
||||
@ -71,6 +73,14 @@ impl MathExt for f32 {
|
||||
self.max(0.0).min(1.0)
|
||||
}
|
||||
|
||||
fn trunc(self) -> f32 {
|
||||
unsafe { core::intrinsics::truncf32(self) }
|
||||
}
|
||||
|
||||
fn fract(self) -> f32 {
|
||||
self - self.trunc()
|
||||
}
|
||||
|
||||
fn signum(self) -> f32 {
|
||||
if self.is_nan() {
|
||||
Self::NAN
|
||||
|
Loading…
Reference in New Issue
Block a user