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

Commit f069b54

Browse files
committed
Decrease the allowed error for cbrt
With the correctly rounded implementation, we can reduce the ULP requirement for `cbrt` to zero. There is still an override required for `i586` because of the imprecise FMA.
1 parent b19cde9 commit f069b54

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

crates/libm-test/src/precision.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
4141
| Bn::Trunc => 0,
4242

4343
// Operations that aren't required to be exact, but our implementations are.
44-
Bn::Cbrt if ctx.fn_ident != Id::Cbrt => 0,
44+
Bn::Cbrt => 0,
4545

4646
// Bessel functions have large inaccuracies.
4747
Bn::J0 | Bn::J1 | Bn::Y0 | Bn::Y1 | Bn::Jn | Bn::Yn => 8_000_000,
@@ -54,7 +54,6 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
5454
Bn::Atan => 1,
5555
Bn::Atan2 => 2,
5656
Bn::Atanh => 2,
57-
Bn::Cbrt => 1,
5857
Bn::Cos => 1,
5958
Bn::Cosh => 1,
6059
Bn::Erf => 1,
@@ -92,6 +91,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
9291
}
9392

9493
match ctx.fn_ident {
94+
Id::Cbrt => ulp = 2,
9595
// FIXME(#401): musl has an incorrect result here.
9696
Id::Fdim => ulp = 2,
9797
Id::Sincosf => ulp = 500,
@@ -119,6 +119,7 @@ pub fn default_ulp(ctx: &CheckCtx) -> u32 {
119119

120120
Id::Asinh => ulp = 3,
121121
Id::Asinhf => ulp = 3,
122+
Id::Cbrt => ulp = 1,
122123
Id::Exp10 | Id::Exp10f => ulp = 1_000_000,
123124
Id::Exp2 | Id::Exp2f => ulp = 10_000_000,
124125
Id::Log1p | Id::Log1pf => ulp = 2,

0 commit comments

Comments
 (0)