diff --git a/collects/scribblings/reference/numbers.scrbl b/collects/scribblings/reference/numbers.scrbl index 41ad7d2d21..e2f4e2ff4d 100644 --- a/collects/scribblings/reference/numbers.scrbl +++ b/collects/scribblings/reference/numbers.scrbl @@ -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]. diff --git a/collects/tests/racket/number.rktl b/collects/tests/racket/number.rktl index 4159d18488..7c55c1ec93 100644 --- a/collects/tests/racket/number.rktl +++ b/collects/tests/racket/number.rktl @@ -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?) diff --git a/src/racket/src/number.c b/src/racket/src/number.c index 5540cd7020..a4cb69b725 100644 --- a/src/racket/src/number.c +++ b/src/racket/src/number.c @@ -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; }