diff --git a/src/core/n-math.c b/src/core/n-math.c index e0046559e0..7ed50170e0 100644 --- a/src/core/n-math.c +++ b/src/core/n-math.c @@ -391,7 +391,9 @@ enum {SINE, COSINE, TANGENT}; ***********************************************************************/ { REBDEC dval = AS_DECIMAL(D_ARG(1)); +#ifdef USE_NO_INFINITY if (dval < 0) Trap0(RE_POSITIVE); +#endif SET_DECIMAL(D_RET, sqrt(dval)); return R_RET; } diff --git a/src/tests/units/decimal-test.r3 b/src/tests/units/decimal-test.r3 index d9f8cd6c2d..5fe7e1eeb0 100644 --- a/src/tests/units/decimal-test.r3 +++ b/src/tests/units/decimal-test.r3 @@ -115,6 +115,16 @@ Rebol [ ] ===end-group=== + +===start-group=== "square-root" + --test-- "square-root 4" + --assert 2.0 = square-root 4 + --test-- "square-root -1" + ;@@ https://github.com/Oldes/Rebol-issues/issues/2431 + --assert "1.#NaN" = mold try [square-root -1] +===end-group=== + + ===start-group=== "decimal issues" --test-- "issue-1753" ;@@ https://github.com/Oldes/Rebol-issues/issues/1753