0

How to return "NaN" using SQRT function in Oracle SQL? Here is my unsuccessful attempt:

SELECT SQRT(4) AS "SQRT of 4",
       SQRT(0) AS "SQRT of 0",
       SQRT(-1) AS "SQRT of -1"
FROM DUAL;

As I understand, a successful query might use the TO_BINARY_DOUBLE function but additional approaches are welcome.

1

Cast the number, as you said:

SELECT SQRT(4) AS "SQRT of 4",
   SQRT(0) AS "SQRT of 0",
   SQRT(TO_BINARY_DOUBLE(-1)) AS "SQRT of -1"
FROM DUAL;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.