[Coco] OS9 HEX to DECIMAL conversion.

coco at jechar.ca coco at jechar.ca
Wed May 16 08:05:17 EDT 2018


I am only interested in INTEGER calculations.

Print Using might be ok for output but It does not help me
convert a HEX input to DECIMAL.

  INTEGER for all intents and purposes is the same as DECIMAL.

  So I am looking for a "String that is a representation of a
  HEX Number to INTEGER version and maybe the inverse though
  maybe PRINT USING will suffice for the output ig it can
  handel large numbers like 400,000+

On 2018-05-16 07:18, James Jones wrote:
> 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