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::*;
19#[allow(unused_imports)]
20pub use trunc::*;
21
22/// Sets the high bit 0x80000000 on a float.
23#[inline(always)]
24pub fn abs(value: f32) -> f32 {
25 f32::from_bits(value.to_bits() & 0x7fffffff)
26}
27
28/// Checks if the high bit 0x80000000 is set on a float.
29#[inline(always)]
30pub fn is_negative(value: f32) -> bool {
31 value.to_bits() >= 0x80000000
32}
33
34/// Checks if the high bit 0x80000000 is not set on a float.
35#[inline(always)]
36pub fn is_positive(value: f32) -> bool {
37 value.to_bits() < 0x80000000
38}
39
40/// Inverts the high bit 0x80000000 on a float.
41#[inline(always)]
42pub fn flipsign(value: f32) -> f32 {
43 f32::from_bits(value.to_bits() ^ 0x80000000)
44}
45
46/// Assigns the high bit 0x80000000 on the sign to the value.
47#[inline(always)]
48pub fn copysign(value: f32, sign: f32) -> f32 {
49 f32::from_bits((value.to_bits() & 0x7fffffff) | (sign.to_bits() & 0x80000000))
50}
51
52#[inline(always)]
53pub fn clamp(value: f32, min: f32, max: f32) -> f32 {
54 let mut x: f32 = value;
55 if x < min {
56 x = min;
57 }
58 if x > max {
59 x = max;
60 }
61 x
62}
63