Page 1 of 1

BODH - a number converter

Posted: Sun Jan 22, 2023 4:59 pm
by Cosi
(I'm not sure if I'm posting this in the correct section, please move my post if there's a more suitable category.)

"Scratching my own itch", I've written a handy number converter for the Organiser. The original version converts numbers between the most commonly used numeral systems: decimal (Dec), hexadecimal (Hex), binary (Bin), and octal (Oct), but by adding literally two lines to the source code (and modifying two other lines), you can add support for any other system.
Due to OPL's technical limitations, only numbers between 0 and 32767 (dec) can be converted.

Source and a pack image:
https://github.com/cosi1/BODH

There's also a new version of my game Psi2048 available:
https://github.com/cosi1/psi2048

Re: BODH - a number converter

Posted: Sun Jan 22, 2023 8:31 pm
by Daren
Just in case you were unaware you can post code directly into the forum post, it makes seeing your code easier than going to an external link. To post code just use the 5 icon above the reply box with the “</>” button, then paste the code in.

Re: BODH - a number converter

Posted: Mon Jan 23, 2023 7:41 am
by Cosi
Thanks for the heads up, Daren. When I come up with something shorter, I'll definitely use this feature :-)

Re: BODH - a number converter

Posted: Mon Mar 06, 2023 9:47 pm
by MartinP
Thanks for posting this, I've been using it to convert some values. Interesting too, to see how it works. I made a few mods for ease of use and to allow bigger numbers, and I also split binary into groups of 4 digits to read them more easily. I forked your github repositry: https://github.com/martinprest/BODH2
On Jaap's website, he has a hex calculator, but it doesn't do binary. I haven't found a use for octal yet, but I guess there must be some, anyway without octal the program name would be BDH, which doesn't have such a nice sound to it.
I feel I should also mention the OPL command HEX$, which only works for converting base 10 to 16.
I also recently rediscovered that in OPL you can put a '$' in front of a number to enter it in hex e.g. $FF = 255, this can be done in CALC also. It doesn't seem to be described much in the Organiser manual, just given in some code examples that use POKE or PEEK.
Martin P.

Re: BODH - a number converter

Posted: Sat Apr 01, 2023 9:37 am
by Cosi
Thanks, Martin! (Also, apologies for the late response.)

Regarding octal conversions, the most obvious use case is Unix file permissions; I don't really use octal that much, but:
without octal the program name would be BDH, which doesn't have such a nice sound to it.
:D