Fix the 2-argument case of atan to conform to the documentation and

fix the documentation.
This commit is contained in:
Vincent St-Amour 2011-02-04 11:59:08 -05:00
parent f7caad524b
commit e9789c6697
3 changed files with 7 additions and 5 deletions

View File

@ -594,13 +594,13 @@ In the one-argument case, returns the arctangent of the inexact
approximation of @racket[z], except that the result is an exact
@racket[0] for an exact @racket[0] argument.
In the two-argument case, the result is roughly the same as @racket[(/
(exact->inexact y) (exact->inexact x))], but the signs of @racket[y]
In the two-argument case, the result is roughly the same as @racket[
(atan (/ (exact->inexact y)) (exact->inexact x))], but the signs of @racket[y]
and @racket[x] determine the quadrant of the result. Moreover, a
suitable angle is returned when @racket[y] divided by @racket[x]
produces @racket[+nan.0] in the case that neither @racket[y] nor
@racket[x] is @racket[+nan.0]. Finally, if @racket[x] is exact
@racket[0] and @racket[y] is an exact positive number, the result is
@racket[x] is @racket[+nan.0]. Finally, if @racket[y] is exact
@racket[0] and @racket[x] is an exact positive number, the result is
exact @racket[0]. If both @racket[x] and @racket[y] are exact
@racket[0], the @exnraise[exn:fail:contract:divide-by-zero].

View File

@ -1843,6 +1843,7 @@
(test 0.0 atan 0.0 0)
(test 0 atan 0 1)
(test 0 atan 0 (expt 2 100))
(test 0 atan 0 5/2)
(test 0.0 atan 0 1.0)
(test 314.0 round (* 100 (atan 0 -1)))
(err/rt-test (atan 0 0) exn:fail:contract:divide-by-zero?)

View File

@ -2243,7 +2243,8 @@ atan_prim (int argc, Scheme_Object *argv[])
ESCAPED_BEFORE_HERE;
}
if ((SCHEME_INTP(n2) && (SCHEME_INT_VAL(n2) > 0))
|| (SCHEME_BIGNUMP(n2) && (SCHEME_BIGPOS(n2))))
|| (SCHEME_BIGNUMP(n2) && (SCHEME_BIGPOS(n2)))
|| (SCHEME_RATIONALP(n2) && scheme_is_positive(n2)))
return zeroi;
}