Invalid Input for this program - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html) +--- Forum: HP Prime (/forum-5.html) +--- Thread: Invalid Input for this program (/thread-18062.html) |
Invalid Input for this program - kingschool9 - 02-21-2022 05:18 AM 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 RE: Invalid Input for this program - Joe Horn - 02-21-2022 01:47 PM 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. RE: Invalid Input for this program - kingschool9 - 02-21-2022 08:27 PM (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 |