Name that calculator  from the program listing...

11122018, 10:17 AM
(This post was last modified: 11122018 12:13 PM by Ángel Martin.)
Post: #7




RE: Name that calculator  from the program listing...
Here's an example using the IF.ELSE.ENDIF structure to calculate the roots of a second degree equation, a.x^2 + b.x + c = 0
The program is *not* optimized for size; the purpose of the example is to show the strings more clearly in the respective branches. Feel free to improve on it, for instance by calculating the value of the discriminant beforehand and reusing it in the appropriate sections. Code: 01 LBL “QRT” On entry the coefficients a,b,c are expected in (Z, Y, X} respectively. On exit the roots are placed in {Y,X} if real (F4 set), or the Imaginary and real parts of the complex conjugate roots (F4 clear). Example: try it for x^2 = 1, that is a=1, b=0, and c=1 Result: x1= 1, x2 = 1 and to exercise the complex branch, how about x^2 + x + 1 = 0 resulting Re(z) = 0.5 ; Im(z) = 0.866025404 Cheers, ÁM 

« Next Oldest  Next Newest »

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