Post Reply 
(15C) Decimal to x/16
09-25-2015, 04:10 PM
Post: #2
RE: HP 15C: Decimal to x/16
That's a nice program. Here's a variant that is a little shorter and uses only one register:

Code:
001-42,21,11    LBL A
002-    44 0    STO 0
003-   42 44    FRAC
004-      48    .
005-       5    5
006-      36    ENTER
007-      36    ENTER
008-   43 33    R^
009-       1    1
010-       6    6
011-      20    *
012-      40    +
013-   43 44    INT
014-      48    .
015-       1    1
016-       6    6
017-      40    +
018-42,21, 0    LBL 0
019-      20    *
020-   42 44    FRAC
021-43,30, 7    TEST 7 ; x>y
022-    22 1    GTO 1
023-   43 35    CLx
024-   43 36    LSTx
025-    22 0    GTO 0
026-42,21, 1    LBL 1
027-    45 0    RCL 0
028-   43 36    LSTx
029-      36    ENTER
030-      40    +
031-   43 32    RTN

The numerator and denominator are merged into a single number nn.dd. Thus we can divide both by 2 with a single instruction.
The display settings aren't changed since the function INT(x + 0.5) is used to round a number.
The stack is filled with 0.5 in lines 4-7 because this number can be used often.
Personally I dislike that 16 occurs twice but I couldn't come up with a better solution. Maybe somebody else can?

Kind regards
Thomas
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(15C) Decimal to x/16 - Dwight Sturrock - 09-24-2015, 11:56 PM
RE: HP 15C: Decimal to x/16 - Thomas Klemm - 09-25-2015 04:10 PM



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