(15C) Decimal to x/16
|
09-24-2015, 11:56 PM
(This post was last modified: 06-15-2017 01:34 PM by Gene.)
Post: #1
|
|||
|
|||
(15C) Decimal to x/16
HP 15c x/16
Program to convert decimal fraction to a fraction readable on a tape measure: Registers: STO 0- ORIGINAL NUMBER STO 1- NUMERATOR STO 2- DENOMINATOR Code: 01 LBL A |
|||
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 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 |
|||
09-26-2015, 02:11 PM
Post: #3
|
|||
|
|||
RE: HP 15C: Decimal to x/16
Elegant, Thomas, and a bit faster.
I had a version for the 42S and I ported it quickly to the 15C years ago without much thought. It is a program I used on a daily basis in my work for many years. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)