(15C) another approach to decimal <-> binary conversion
11-30-2017, 07:50 PM
Post: #2
 Dieter Senior Member Posts: 2,397 Joined: Dec 2013
RE: (15C) another approach to decimal <-> binary conversion
(11-29-2017 10:32 AM)jthole Wrote:  I've written my own conversion (not using an existing program as the basis, so I surely have made beginner mistakes), which prefixes the number with a "8". That makes sure the leading zeros are preserved, and can be easily read as "B" for binary ;-)

Ah, that's what the "8" is for. #-)

(11-29-2017 10:32 AM)jthole Wrote:  To start the program, input the decimal number you want to convert (no need to press enter), and press R/S.

If the program happens to be set to step 000 or 001, that is.

The five keys A...E on the 15C are there to avoid exactly this problem. Press f[A] and the program starts at LBL A. Or B, C, D or E, respectively. That's what these keys are for. In user mode you don't even have to press the [f] prefix.

So you should not waste these useful labels A...E for simple loops or the like. Have you program start with LBL A and replace the existing LBL A with, say LBL 0 or LBL 1 or another numeric label.

(11-29-2017 10:32 AM)jthole Wrote:  The binary number is returned in the X register (in reverse).

Not if you turn the calculator upside down. This was even the "b" becomes a suffix that makes sense: 81111000 then can be read as 0001111B. :-)

And finally... what about a version that returns a result in the correct order ?-)

Dieter
 « Next Oldest | Next Newest »

 Messages In This Thread (15C) another approach to decimal <-> binary conversion - jthole - 11-29-2017, 10:32 AM RE: (15C) another approach to decimal <-> binary conversion - Dieter - 11-30-2017 07:50 PM RE: (15C) another approach to decimal <-> binary conversion - jthole - 12-01-2017, 08:48 AM RE: (15C) another approach to decimal <-> binary conversion - Thomas Klemm - 09-01-2018, 06:16 PM

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