Convert hex string to decimal

All aspects of programming on the Commander X16.
Post Reply
Martin Schmalenbach
Posts: 140
Joined: Tue Jul 21, 2020 10:08 pm

Convert hex string to decimal

Post by Martin Schmalenbach »

We have the wonderful HEX$() and BIN$() functions.

Do we have plans for the reverse - an extension to the VAL() function to cope with HEX and BIN strings being supplied?
kelli217
Posts: 542
Joined: Sun Jul 05, 2020 11:27 pm

Re: Convert hex string to decimal

Post by kelli217 »

It's been discussed on the Discord. I believe it's underway.
Martin Schmalenbach
Posts: 140
Joined: Tue Jul 21, 2020 10:08 pm

Re: Convert hex string to decimal

Post by Martin Schmalenbach »

Thanks for letting me know - sounds good!
mobluse
Posts: 177
Joined: Tue Aug 04, 2020 2:16 pm
Location: Lund, Sweden
Contact:

Re: Convert hex string to decimal

Post by mobluse »

I have written an X16 BASIC program to convert between arbitrary bases called baseconv.bas:
https://github.com/mobluse/chargen-make ... seconv.bas
You can paste it into the emulator.
Usage example:
RUN
IN BASE,OUT BASE,NUMBER? 16,10,ABCD
BASES:
 IN I= 16
 OUT O= 10
43981

READY.
RUN
IN BASE,OUT BASE,NUMBER? 10,16,43981
BASES:
 IN I= 10
 OUT O= 16
ABCD

READY.
X16&C64 Quiz: Try It Now! Huge Char Demo: Try It Now! DECPS: Try It Now! Aritm: Try It Now!
Martin Schmalenbach
Posts: 140
Joined: Tue Jul 21, 2020 10:08 pm

Re: Convert hex string to decimal

Post by Martin Schmalenbach »

Fantastic - thank you !
mortarm
Posts: 321
Joined: Tue May 16, 2023 6:21 pm

Re: Convert hex string to decimal

Post by mortarm »

mobluse wrote: Tue Jul 04, 2023 9:27 pm I have written an X16 BASIC program to convert between arbitrary bases called baseconv.bas:
https://github.com/mobluse/chargen-make ... seconv.bas
You can paste it into the emulator.
Usage example:
RUN
IN BASE,OUT BASE,NUMBER? 16,10,ABCD
BASES:
 IN I= 16
 OUT O= 10
43981
Now that's classic micro programming. There were a ton of such programs in the early days of home computing. These days, however, you can find a ton of these online, which are more useful thanks to the multi-tasking OSes we have today.
Post Reply