Skip to content

Commit 57d4552

Browse files
committed
Combine the source files for fmod
Since `fmod` is generic, there isn't any need to have the small wrappers in separate files. Most operations was done in [1] but `fmod` was omitted until now. [1]: rust-lang#537
1 parent 523f151 commit 57d4552

File tree

6 files changed

+24
-27
lines changed

6 files changed

+24
-27
lines changed

src/math/fmod.rs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
1+
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
2+
#[cfg(f16_enabled)]
3+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
4+
pub fn fmodf16(x: f16, y: f16) -> f16 {
5+
super::generic::fmod(x, y)
6+
}
7+
8+
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
9+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
10+
pub fn fmodf(x: f32, y: f32) -> f32 {
11+
super::generic::fmod(x, y)
12+
}
13+
114
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
215
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
316
pub fn fmod(x: f64, y: f64) -> f64 {
417
super::generic::fmod(x, y)
518
}
19+
20+
/// Calculate the remainder of `x / y`, the precise result of `x - trunc(x / y) * y`.
21+
#[cfg(f128_enabled)]
22+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
23+
pub fn fmodf128(x: f128, y: f128) -> f128 {
24+
super::generic::fmod(x, y)
25+
}

src/math/fmodf.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/math/fmodf128.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/math/fmodf16.rs

Lines changed: 0 additions & 5 deletions
This file was deleted.

src/math/frexp.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)]
12
pub fn frexp(x: f64) -> (f64, i32) {
23
let mut y = x.to_bits();
34
let ee = ((y >> 52) & 0x7ff) as i32;

src/math/mod.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -260,8 +260,7 @@ pub use self::fma_wide::fmaf;
260260
pub use self::fmin_fmax::{fmax, fmaxf, fmin, fminf};
261261
pub use self::fminimum_fmaximum::{fmaximum, fmaximumf, fminimum, fminimumf};
262262
pub use self::fminimum_fmaximum_num::{fmaximum_num, fmaximum_numf, fminimum_num, fminimum_numf};
263-
pub use self::fmod::fmod;
264-
pub use self::fmodf::fmodf;
263+
pub use self::fmod::{fmod, fmodf};
265264
pub use self::frexp::frexp;
266265
pub use self::frexpf::frexpf;
267266
pub use self::hypot::hypot;
@@ -318,10 +317,6 @@ pub use self::trunc::{trunc, truncf};
318317

319318
cfg_if! {
320319
if #[cfg(f16_enabled)] {
321-
// verify-sorted-start
322-
mod fmodf16;
323-
// verify-sorted-end
324-
325320
// verify-sorted-start
326321
pub use self::ceil::ceilf16;
327322
pub use self::copysign::copysignf16;
@@ -331,7 +326,7 @@ cfg_if! {
331326
pub use self::fmin_fmax::{fmaxf16, fminf16};
332327
pub use self::fminimum_fmaximum::{fmaximumf16, fminimumf16};
333328
pub use self::fminimum_fmaximum_num::{fmaximum_numf16, fminimum_numf16};
334-
pub use self::fmodf16::fmodf16;
329+
pub use self::fmod::fmodf16;
335330
pub use self::ldexp::ldexpf16;
336331
pub use self::rint::rintf16;
337332
pub use self::round::roundf16;
@@ -348,10 +343,6 @@ cfg_if! {
348343

349344
cfg_if! {
350345
if #[cfg(f128_enabled)] {
351-
// verify-sorted-start
352-
mod fmodf128;
353-
// verify-sorted-end
354-
355346
// verify-sorted-start
356347
pub use self::ceil::ceilf128;
357348
pub use self::copysign::copysignf128;
@@ -362,7 +353,7 @@ cfg_if! {
362353
pub use self::fmin_fmax::{fmaxf128, fminf128};
363354
pub use self::fminimum_fmaximum::{fmaximumf128, fminimumf128};
364355
pub use self::fminimum_fmaximum_num::{fmaximum_numf128, fminimum_numf128};
365-
pub use self::fmodf128::fmodf128;
356+
pub use self::fmod::fmodf128;
366357
pub use self::ldexp::ldexpf128;
367358
pub use self::rint::rintf128;
368359
pub use self::round::roundf128;

0 commit comments

Comments
 (0)