HP 50g Binary Number Formatting
|
04-23-2022, 01:38 PM
(This post was last modified: 04-23-2022 10:14 PM by Gil.)
Post: #2
|
|||
|
|||
RE: HP 50g Binary Number Formatting
1) Place your binary digits as a string in the stack.
"1110 1101" 2) Execute —>BIN4 (file here included as "—>BIN4.Doc" Note: - The ending .Doc is not a Word document. - You can simply download that file into your calculator - and save it in your calculator as —>BIN4). Code for —>BIN4: « DUP DUP SIZE "" str.ORIGIN size.ORIGIN str.NEW « size.ORIGIN 4 MOD 4 SWAP - DUP m m.ORIGIN « size.ORIGIN m + 4 / loop « WHILE m 0 REPEAT " " str.ORIGIN + 'str.ORIGIN' STO -1 'm' STO+ END 1 loop FOR i str.NEW str.ORIGIN i 1 - 4 * 1 + DUP 3 + SUB + " " + 'str.NEW' STO NEXT str.NEW m.ORIGIN 4 MOD 1 + str.NEW SIZE 1 - SUB » » » » Or \\<< DUP DUP SIZE \"\" \\-> str.ORIGIN size.ORIGIN str.NEW \\<< size.ORIGIN 4 MOD 4 SWAP - DUP \\-> m m.ORIGIN \\<< size.ORIGIN m + 4 / \\-> loop \\<< WHILE m 0 \\=/ REPEAT \" \" str.ORIGIN + 'str.ORIGIN' STO -1 'm' STO+ END 1 loop FOR i str.NEW str.ORIGIN i 1 - 4 * 1 + DUP 3 + SUB + \" \" + 'str.NEW' STO NEXT str.NEW m.ORIGIN 4 MOD 1 + str.NEW SIZE 1 - SUB \\>> \\>> \\>> \\>> It's a rough solution that should work fine, though it could be bettered in terms of code. Hope it might help. Regards, Gil Campart |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)