summaryrefslogtreecommitdiffstats
path: root/vendor/libm-0.1.4/src/math/modff.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-18 02:49:50 +0000
commit9835e2ae736235810b4ea1c162ca5e65c547e770 (patch)
tree3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/libm-0.1.4/src/math/modff.rs
parentReleasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff)
downloadrustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz
rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/libm-0.1.4/src/math/modff.rs')
-rw-r--r--vendor/libm-0.1.4/src/math/modff.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/vendor/libm-0.1.4/src/math/modff.rs b/vendor/libm-0.1.4/src/math/modff.rs
new file mode 100644
index 000000000..56ece12e3
--- /dev/null
+++ b/vendor/libm-0.1.4/src/math/modff.rs
@@ -0,0 +1,33 @@
+pub fn modff(x: f32) -> (f32, f32) {
+ let rv2: f32;
+ let mut u: u32 = x.to_bits();
+ let mask: u32;
+ let e = ((u >> 23 & 0xff) as i32) - 0x7f;
+
+ /* no fractional part */
+ if e >= 23 {
+ rv2 = x;
+ if e == 0x80 && (u << 9) != 0 {
+ /* nan */
+ return (x, rv2);
+ }
+ u &= 0x80000000;
+ return (f32::from_bits(u), rv2);
+ }
+ /* no integral part */
+ if e < 0 {
+ u &= 0x80000000;
+ rv2 = f32::from_bits(u);
+ return (x, rv2);
+ }
+
+ mask = 0x007fffff >> e;
+ if (u & mask) == 0 {
+ rv2 = x;
+ u &= 0x80000000;
+ return (f32::from_bits(u), rv2);
+ }
+ u &= !mask;
+ rv2 = f32::from_bits(u);
+ return (x - rv2, rv2);
+}