BBC BASIC for Windows
Programming >> BBC BASIC language >> Decimal to Hexadecimal converter (Tool) http://bb4w.conforums.com/index.cgi?board=language&action=display&num=1459146935 Decimal to Hexadecimal converter (Tool)
Post by michael on Mar 28th, 2016, 06:35am
This should be right. Now you can make those fast Hexadecimals in your program.. Its ready to compile and then you can execute it, and resize the window and place it where you want for quick conversion.. Code:
10 PRINT
20 PRINT "Enter a number "
30 INPUT number
40 PRINT "The hexadecimal is :"
50 PRINT "&"+STR$~(number)
60 PRINT "Press ENTER to clear the screen and convert more"
70 INPUT A$
80 CLS
90 GOTO 10
Re: Decimal to Hexadecimal converter (Tool)
Post by Zaphod on Mar 28th, 2016, 4:14pm
I am wondering why you would not just go to immediate mode and type PRINT ~123 or PRINT &7B to convert in either direction. It seems pretty simple to me or am I missing some vital point.
Re: Decimal to Hexadecimal converter (Tool)
Post by michael on Mar 28th, 2016, 4:37pm
Quote:
Hex is so embedded in computers that BBC BASIC will even print it for us. In order to convert a number in decimal to a string representation in hex use STR$ with tilde:
PRINT STR$~(255)
To convert a number back from hex to decimal use: PRINT EVAL ("&FFE")
This is my source. I am still trying to learn. I make modules from what I learn and apply and improve the modules as I advance in programming technique. Also, this tool became necessary for me since Richard told me of a more efficient way to do calculations.
I needed a tool to convert decimal to hexadecimal.. and so this became the quick solution.. Also there may be a future use for this tool in other projects.. (no idea) Immediate mode.. I found it.. thanks..