Post Reply 
Invalid Input for this program
02-21-2022, 05:18 AM
Post: #1
Invalid Input for this program
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
Find all posts by this user
Quote this message in a reply
02-21-2022, 01:47 PM
Post: #2
RE: Invalid Input for this program
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.

<0|ɸ|0>
-Joe-
Visit this user's website Find all posts by this user
Quote this message in a reply
02-21-2022, 08:27 PM
Post: #3
RE: Invalid Input for this program
(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
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)