HP Forums

Full Version: Invalid Input for this program
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ive been trying to add some functions to my calculator one of which is a quadratic solver. My code is:
```
EXPORT quadratic(A,B,C)
BEGIN

//Error: Pinpointed to be the - sign in the square root
RETURN [(-B+√((B^2)-4*A*C))/(2*A),(-B-√((B^2)-4*A*C))/(2*A)];
END;

```
It's quite simple but it fails. Checking the code, there are no syntax errors, but running it with quadratic(5,6,7) would give Error: Invalid input. I managed to debug and find the problem at the - sign under the square root. Any help would be appreciated
Press Shift Home (Settings), left-cursor twice, and then press [+] to turn on the option to "Allow complex output from real input". This will allow your Prime to calculate the square roots of negative values.
(02-21-2022 01:47 PM)Joe Horn Wrote: [ -> ]Press Shift Home (Settings), left-cursor twice, and then press [+] to turn on the option to "Allow complex output from real input". This will allow your Prime to calculate the square roots of negative values.

Thanks for the help. I had managed to actually fix my problem before this thread got approved by changing sqrt to CAS.sqrt which was able to solve the problem but I just now also enabled complex output as you mentioned. Thanks
Reference URL's