Page 1 of 1
Convert hex string to decimal
Posted: Sun Jul 02, 2023 6:03 am
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?
Re: Convert hex string to decimal
Posted: Mon Jul 03, 2023 7:37 pm
by kelli217
It's been discussed on the Discord. I believe it's underway.
Re: Convert hex string to decimal
Posted: Tue Jul 04, 2023 2:42 am
by Martin Schmalenbach
Thanks for letting me know - sounds good!
Re: Convert hex string to decimal
Posted: Tue Jul 04, 2023 9:27 pm
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.
Re: Convert hex string to decimal
Posted: Wed Jul 05, 2023 6:58 pm
by Martin Schmalenbach
Fantastic - thank you !
Re: Convert hex string to decimal
Posted: Wed Aug 09, 2023 2:49 pm
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.