13.07.2015 Views

Turbo Basic

Turbo Basic

Turbo Basic

SHOW MORE
SHOW LESS
  • No tags were found...

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Following is a program that demonstrates <strong>Turbo</strong> <strong>Basic</strong>'s internal single-precisionformat.a! = 167.25address = VARPTR(a!)FOR n = 0 TO 3byteval = PEEK(addresstn)PRINT HEX$(byteval)NEXT nI address1 points to a!I default segment is okayLet's decode these 4-byte values that supposedly represent 167.25 into singleprecisionform. First, rearrange them so that the most-significant byte comes first:43 27 40 00Now break them into binary:Hex 4 3 2 7 4° ° °Binary 0100 0010 0010 0111 0100 0000 0000 0000Now break it into sign bit, exponent, and normalized mantissa:sign exponent mantissaBinary ..... 1 ___ 0 __----1___10_0_00_1_10 __..........__0_10_0_111_0_10_0_00_0_0o_00_00_0_0_0----1Subtract the 7FH bias from the exponent:86H - 7FH = true binary exponent of 7A normalized mantissa has an assumed 1 and a binary point at the extreme left,so the mantissa is really1.01001110100000000000000Shifting the binary point right seven places to adjust for the exponent results in10100111.0100000000000000 = 167.25388 <strong>Turbo</strong> <strong>Basic</strong> Owner's Handbook

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!