[Coco] OS9 HEX to DECIMAL conversion.
Wayne Campbell
asa.rand at gmail.com
Wed May 16 09:11:14 EDT 2018
her = hex
On Wed, May 16, 2018, 6:10 AM Wayne Campbell <asa.rand at gmail.com> wrote:
> The first problem you're going to run into is that the maximum integer
> value you can have in Basic09 is 32767. There are no unsigned integers. You
> can use REAL numbers to get integer values >32767, but it there may be a
> trailing fraction (such as .00000001 or something like that) that you will
> have to deal with. Basic09 has a way of dealing with her values, but again
> it is limited to the maximum value of FFFF or -1 unsigned. It is the $
> character preceding the value (such as $A9C4). I don't know of any routine
> for handling large integers in Basic09.
>
>
> On Wed, May 16, 2018, 5: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+
>>
>> 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
>> >>
>>
>> --
>> Coco mailing list
>> Coco at maltedmedia.com
>> https://pairlist5.pair.net/mailman/listinfo/coco
>>
>
More information about the Coco
mailing list