REM Calculates large 1024*terabyte hexidecimal values.
REM $INCLUDE: 'format.bi'
DIM x AS DOUBLE
DIM z1 AS DOUBLE
DIM z2 AS DOUBLE
DIM z3 AS DOUBLE
DIM z4 AS DOUBLE
CLS
' maximum extended fat32 long = ffff ffff ffff ffffh
FOR q = 1 TO 10
   x = 2 ^ q
   GOSUB calc
NEXT
END
calc:
PRINT x; "1024*terabyte extended"
x = x * 1024 ^ 5 - 1 ' <x> 1024*TB.
PRINT "fat32="; FormatD$(x, "#,##0;;"); "=hex:";
z1 = x - INT(x / &H10000) * &H10000 ' 0000 0000 0000 ffff
x = x - z1: x = x / &H10000
z2 = x - INT(x / &H10000) * &H10000 ' 0000 0000 ffff 0000
x = x - z2: x = x / &H10000
z3 = x - INT(x / &H10000) * &H10000 ' 0000 ffff 0000 0000
x = x - z3: x = x / &H10000
z4 = x                              ' ffff 0000 0000 0000
x = x - z4: x = x / &H10000 ' x should now equal zero.
PRINT RIGHT$("0000" + HEX$(z4), 4);
PRINT RIGHT$("0000" + HEX$(z3), 4); " ";
PRINT RIGHT$("0000" + HEX$(z2), 4);
PRINT RIGHT$("0000" + HEX$(z1), 4); " ";
x = 0
x = z1 + z2 * &H10000 + z3 * &H10000 * &H10000 + z4 * &H10000 * &H10000 * &H10000
PRINT "("; FormatD$(x, "#,##0;;"); ")"' should equal original definition
RETURN

