Skip to content

Make (acos 1) return exact zero #621

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 28, 2024
Merged

Conversation

jpellegrini
Copy link
Contributor

@jpellegrini jpellegrini commented Mar 27, 2024

Previously we had

stklos> (acos 1)
0.0
stklos> (asin 0)
0

Hm, we have anice precise result for (asin 0), why not for
(acos 1)? It's because for asin, we have:

    case tc_integer:  if (z == MAKE_INT(0)) return MAKE_INT(0);
                      return asin_real(INT_VAL(z));

and for acos, we were also testing for exact zero, and then we returned inexact pi/2:

    case tc_integer:  if (z == MAKE_INT(0)) return div2(double2real(MY_PI),
                                                        MAKE_INT(2));

But that's not necessary, because acos_real will do that anyway. And we were not testing for the nice case of (acos 1). Now we do that.

One test was also adjusted.

Previously we had

stklos> (acos 1)
0.0
stklos> (asin 0)
0

Hm, we have anice precise result for `(asin 0)`, why not for
`(acos 1)`?   It's because for asin, we have:

```
    case tc_integer:  if (z == MAKE_INT(0)) return MAKE_INT(0);
                      return asin_real(INT_VAL(z));
```

and for acos, we were also testing for exact zero, and then we
returned inexact pi/2:

```
    case tc_integer:  if (z == MAKE_INT(0)) return div2(double2real(MY_PI),
                                                        MAKE_INT(2));
```

But that's not necessary, because `acos_real` will do that anyway. And
we were not testing for the nice case of `(acos 1)`. Now we do that.

One test was also adjusted.
@jpellegrini jpellegrini changed the title Make (acos 1) return exact zero Make (acos 1) return exact zero Mar 27, 2024
@egallesio egallesio merged commit ea61697 into egallesio:master Mar 28, 2024
@egallesio
Copy link
Owner

Hi @jpellegrini,

That's perfect. Thanks.
Merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants