[Coco] OS9 HEX to DECIMAL conversion.
Wayne Campbell
asa.rand at gmail.com
Wed May 16 12:43:16 EDT 2018
Curtis,
The $ operator, so far as I've ever been able to determine, does not
convert decimal to hex. What it does is tells Basic09 to treat the number
following it as a hexadecimal number. This means that $10 is stored in the
i-code as 0010, not 000A.
On Wed, May 16, 2018, 8:02 AM L. Curtis Boyle <curtisboyle at sasktel.net>
wrote:
> Wayne is correct in that INTEGER is signed only. So if you input a value
> of $8000 or more, it will become a negative number.
> Having said that, BASIC09 does have a built in hex to decimal conversion.
> You just need to add a ‘$’ at the start of the number. You can either
> prompt the user to ‘Add a ‘$’ in front of the number for hexadecimal’, or
> you can check if the first character in your string (with
> LEFT$(stringvar,1)) is not a ‘$’, and then add it your self. When you do a
> VAL(stringvar), it will return the decimal version. (I should note, because
> of how BASIC09’s internal variable analyzing routine works, that the signed
> 16 bit limit even applies to you assigning it to a REAL variable; BASIC09
> internally treats ‘$’ numbers as 16 bit signed bits irregardless; Assigning
> it to a REAL makes it the same number as it does with INTEGER, just in REAL
> format).
>
> L. Curtis Boyle
> curtisboyle at sasktel.net
>
>
>
> > On May 16, 2018, at 6:05 AM, coco at jechar.ca wrote:
> >
> >
> > 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+
>
>
> --
> Coco mailing list
> Coco at maltedmedia.com
> https://pairlist5.pair.net/mailman/listinfo/coco
>
More information about the Coco
mailing list