egallesio / STklos

STklos Scheme
http://stklos.net
GNU General Public License v2.0
67 stars 17 forks source link

Make `(acos 1)` return exact zero #621

Closed jpellegrini closed 3 months ago

jpellegrini commented 3 months ago

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.

egallesio commented 3 months ago

Hi @jpellegrini,

That's perfect. Thanks. Merged.