Post Reply 
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


Attached File(s)
.doc  —>BIN4.Doc (Size: 405 bytes / Downloads: 2)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
HP 50g Binary Number Formatting - aaron - 04-20-2022, 05:47 PM
RE: HP 50g Binary Number Formatting - Gil - 04-23-2022 01:38 PM
RE: HP 50g Binary Number Formatting - Gil - 04-23-2022, 06:01 PM
RE: HP 50g Binary Number Formatting - Gil - 04-23-2022, 06:50 PM
RE: HP 50g Binary Number Formatting - Gil - 04-24-2022, 12:03 AM
RE: HP 50g Binary Number Formatting - 3298 - 04-24-2022, 10:40 AM
RE: HP 50g Binary Number Formatting - Gil - 04-24-2022, 11:34 AM
RE: HP 50g Binary Number Formatting - Gil - 04-25-2022, 04:04 PM
RE: HP 50g Binary Number Formatting - Gil - 04-25-2022, 10:34 PM



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