Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 2a03ae6

Browse files
committed
Add tests against MPFR for scalbn{f} and ldexp{f}
1 parent e6907f5 commit 2a03ae6

File tree

2 files changed

+31
-5
lines changed

2 files changed

+31
-5
lines changed

crates/libm-test/src/mpfloat.rs

+31-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use az::Az;
99
use rug::Assign;
1010
pub use rug::Float as MpFloat;
1111
use rug::float::Round::Nearest;
12-
use rug::ops::{PowAssignRound, RemAssignRound};
12+
use rug::ops::{MulAssignRound, PowAssign, PowAssignRound, RemAssignRound};
1313

1414
use crate::{Float, MathOp};
1515

@@ -270,6 +270,36 @@ macro_rules! impl_op_for_ty {
270270
}
271271
}
272272

273+
// `ldexp` and `scalbn` are the same for binary floating point, so just forward all
274+
// methods.
275+
impl MpOp for crate::op::[<ldexp $suffix>]::Routine {
276+
type MpTy = <crate::op::[<scalbn $suffix>]::Routine as MpOp>::MpTy;
277+
278+
fn new_mp() -> Self::MpTy {
279+
<crate::op::[<scalbn $suffix>]::Routine as MpOp>::new_mp()
280+
}
281+
282+
fn run(this: &mut Self::MpTy, input: Self::RustArgs) -> Self::RustRet {
283+
<crate::op::[<scalbn $suffix>]::Routine as MpOp>::run(this, input)
284+
}
285+
}
286+
287+
impl MpOp for crate::op::[<scalbn $suffix>]::Routine {
288+
type MpTy = (MpFloat, MpFloat);
289+
290+
fn new_mp() -> Self::MpTy {
291+
(new_mpfloat::<Self::FTy>(), new_mpfloat::<Self::FTy>())
292+
}
293+
294+
fn run(this: &mut Self::MpTy, input: Self::RustArgs) -> Self::RustRet {
295+
this.0.assign(input.0);
296+
this.1.assign(2.0);
297+
this.1.pow_assign(input.1);
298+
let ord = this.0.mul_assign_round(&this.1, Nearest);
299+
prep_retval::<Self::FTy>(&mut this.0, ord)
300+
}
301+
}
302+
273303
impl MpOp for crate::op::[<sincos $suffix>]::Routine {
274304
type MpTy = (MpFloat, MpFloat);
275305

crates/libm-test/tests/multiprecision.rs

-4
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,10 @@ libm_macros::for_each_function! {
5555
frexpf,
5656
ilogb,
5757
ilogbf,
58-
ldexp,
59-
ldexpf,
6058
modf,
6159
modff,
6260
remquo,
6361
remquof,
64-
scalbn,
65-
scalbnf,
6662

6763
// FIXME: test needed, see
6864
// https://github.com/rust-lang/libm/pull/311#discussion_r1818273392

0 commit comments

Comments
 (0)