1mod as_i32;
2mod atan;
3mod atan2;
4mod ceil;
5mod floor;
6mod fract;
7mod get_bitmap;
8mod sqrt;
9mod trunc;
10
11pub use as_i32::*;
12pub use atan::*;
13pub use atan2::*;
14pub use ceil::*;
15pub use floor::*;
16pub use fract::*;
17pub use get_bitmap::*;
18pub use sqrt::*;
19pub use trunc::*;
20
21/// Sets the high bit 0x80000000 on a float.
22#[inline(always)]
23pub fn abs(value: f32) -> f32 {
24 f32::from_bits(value.to_bits() & 0x7fffffff)
25}
26
27/// Checks if the high bit 0x80000000 is set on a float.
28#[inline(always)]
29pub fn is_negative(value: f32) -> bool {
30 value.to_bits() >= 0x80000000
31}
32
33/// Checks if the high bit 0x80000000 is not set on a float.
34#[inline(always)]
35pub fn is_positive(value: f32) -> bool {
36 value.to_bits() < 0x80000000
37}
38
39/// Inverts the high bit 0x80000000 on a float.
40#[inline(always)]
41pub fn flipsign(value: f32) -> f32 {
42 f32::from_bits(value.to_bits() ^ 0x80000000)
43}
44
45/// Assigns the high bit 0x80000000 on the sign to the value.
46#[inline(always)]
47pub fn copysign(value: f32, sign: f32) -> f32 {
48 f32::from_bits((value.to_bits() & 0x7fffffff) | (sign.to_bits() & 0x80000000))
49}
50
51#[inline(always)]
52pub fn clamp(value: f32, min: f32, max: f32) -> f32 {
53 let mut x: f32 = value;
54 if x < min {
55 x = min;
56 }
57 if x > max {
58 x = max;
59 }
60 x
61}
62