Skip to content

Commit ba4bc97

Browse files
committed
Add tests against MPFR for ilogb and ilogbf
1 parent ff15e46 commit ba4bc97

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

crates/libm-test/src/mpfloat.rs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,29 @@ macro_rules! impl_op_for_ty {
277277
}
278278
}
279279

280+
impl MpOp for crate::op::[<ilogb $suffix>]::Routine {
281+
type MpTy = MpFloat;
282+
283+
fn new_mp() -> Self::MpTy {
284+
new_mpfloat::<Self::FTy>()
285+
}
286+
287+
fn run(this: &mut Self::MpTy, input: Self::RustArgs) -> Self::RustRet {
288+
this.assign(input.0);
289+
290+
// `get_exp` follows `frexp` for `0.5 <= |m| < 1.0`. Adjust the exponent by
291+
// one to scale the significand to `1.0 <= |m| < 2.0`.
292+
this.get_exp().map(|v| v - 1).unwrap_or_else(|| {
293+
if this.is_infinite() {
294+
i32::MAX
295+
} else {
296+
// Zero or NaN
297+
i32::MIN
298+
}
299+
})
300+
}
301+
}
302+
280303
impl MpOp for crate::op::[<jn $suffix>]::Routine {
281304
type MpTy = MpFloat;
282305

crates/libm-test/tests/multiprecision.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,6 @@ libm_macros::for_each_function! {
5151
],
5252
skip: [
5353
// FIXME: MPFR tests needed
54-
ilogb,
55-
ilogbf,
5654
remquo,
5755
remquof,
5856

@@ -150,9 +148,5 @@ libm_macros::for_each_function! {
150148
scalbnf,
151149
yn,
152150
ynf,
153-
154-
// FIXME: MPFR tests needed
155-
ilogb,
156-
ilogbf,
157151
],
158152
}

0 commit comments

Comments
 (0)