Post Reply 
Cadillac Quadratic Solver behaving like an Edsel - Problem solved!!
09-16-2014, 02:49 AM
Post: #15
RE: Cadillac Quadratic Solver behaving like an Edsel - Problem solved!!
This subroutine should substitute for SGN, change register Z to something you're happy to lose.

Code:
        LBL S
        x=0?
        x^2             Get Last X correct for a zero input
        x=0?
        RTN             Finished with zero input
        R^
        STO Z           Save T in a register
        Rv
        ABS             |x| / x is SGN(x) for x not zero
        Last X
        /
        R^              Now restore T from the register
        CLx             Disable stack lift
        RCL Z
        Rv
        RTN             Finished

This routine doesn't damage the stack and returns with the correct result and the correct value in Last X. I'm sure someone will be able to improve this.

Then replace SGN with XEQ S in you program.


Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Cadillac Quadratic Solver behaving like an Edsel - Problem solved!! - Paul Dale - 09-16-2014 02:49 AM



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