[Coco] BASIC09 - unsigned INTEGERs?

Allen Huffman alsplace at pobox.com
Sat Jan 31 20:46:58 EST 2015


> On Jan 31, 2015, at 11:51 AM, L. Curtis Boyle <curtisboyle at sasktel.net> wrote:
> 
> I am pretty sure you can assign regs.x*65536.+regs.u to a FLOAT variable and it works fine… we used to do this at work all the time.


Nope.

When it does the math, regs.U is -4601 or whatever on mine, so it does the first part, then subtracts -4601. It was driving me nuts, ‘cause the HEX was printing perfectly (PRINT USING) but the REAL was wrong. I ended up printing each value and that’s when I realized what was going on.

DIM a:INTEGER
DIM b:INTEGER
DIM c:REAL

a = $0002
b = $FFFF
c = a * 65536 + b

Expected result:

$0002 * 65536 + $FFFF
2 * 65566 + 65535 = 327679

Actual:

2 * 65536 + -1 = 131071

		— A






More information about the Coco mailing list