[Coco] OS9 HEX to DECIMAL conversion.
L. Curtis Boyle
curtisboyle at sasktel.net
Wed May 16 11:02:42 EDT 2018
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+
More information about the Coco
mailing list