[Coco] OS9 HEX to DECIMAL conversion.
James Jones
jejones3141 at gmail.com
Wed May 16 07:18:12 EDT 2018
As Bob points out, PRINT USING will let you display a value in hexadecimal.
For input, you'll have to write code to do the conversion.
One thing that's important to keep straight: there are languages that have
a decimal numeric format, most notably COBOL, and some computers have an
internal decimal numeric format, BCD, with four bits for each decimal
digit, to support such languages. However, BASIC09's numeric types, BYTE,
INTEGER, and REAL, are binary. The code you write to convert a string of
hex digits will convert that string to an INTEGER or a REAL, not to
decimal, to allow the calculations you want to perform. To see this, try
this code:
DIM sum:REAL
DIM i:INTEGER
FOR i:=1 TO 100
sum:=sum+0.1
NEXT i
PRINT sum
(Back when BASIC09 was new, I wasn't familiar enough with Chinese food to
chuckle at "DIM sum"...)
On Tue, May 15, 2018 at 6:24 PM, <coco at jechar.ca> wrote:
>
>
> Does anyone know of a routine to turn hex to decimal
> or decimal to hex in Basic09.
>
> I would like to take a Hex # as input convert it to decimal
> do some calculations and then convert it back to hex for
> display.
>
> Charles
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
More information about the Coco
mailing list