Post Reply 
HP 50g: Neighbour Function (Dedekind Cut) Programme Challenge
09-27-2017, 03:12 PM (This post was last modified: 09-27-2017 03:13 PM by David Hayden.)
Post: #17
RE: HP 50g: Neighbour Function (Dedekind Cut) Programme Challenge
Slow and simple, but it works. This just keeps adding or subtracting 10^n for successively larger values of n until X+10^n changes.
Code:
@ NEIGHBOR
@ Given X & Y (X on lvl2, Y on lvl1), find the next
@ number to X in the direction of Y that the calc can
@ represent.  If X=Y then return X
«
OVER - SIGN  @ X (-1,0,1)
1E-499 *
IF DUP THEN  @ Special case for X==Y
    WHILE DUP2 + PICK3 ==
    REPEAT
       10. *
    END
END
+
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: HP 50g: Neighbour Function (Dedekind Cut) Programme Challenge - David Hayden - 09-27-2017 03:12 PM



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