:''Explanation:'' [[EOF]] will return 0 until a file ends. NOT converts 0 to -1 so that the loop continues to run. When EOF becomes -1, NOT converts it to 0 to end the loop.
''Example 3:'' So why does '''NOT 5 = -6'''? Because NOT changes every bit of a value into the opposite:
{{CodeStart}}{{Cl|PRINT}} {{Cl|NOT}} 5
{{Cl|PRINT}}
ReadBits 5
ReadBits -6
{{Cl|SUB}} ReadBits (n {{Cl|AS}} {{Cl|INTEGER}}) 'change type value and i bit reads for other whole type values
{{Cl|FOR...NEXT|FOR}} i = 15 {{Cl|TO}} 0 {{Cl|STEP}} -1 'see the 16 bit values
{{Cl|IF...THEN|IF}} n {{Cl|AND (boolean)|AND}} 2 ^ i {{Cl|THEN}} {{Cl|PRINT}} "1"; {{Cl|ELSE}} {{Cl|PRINT}} "0";
{{Cl|NEXT}}
{{Cl|PRINT}}
{{Cl|END SUB}} '' ''
{{CodeEnd}}
{{OutputStart}}-6
0000000000000101
1111111111111010
{{OutputEnd}}
:''Explanation:'' The bit values of an [[INTEGER]] are 2 [[_BYTE]]s and each bit is an exponent of 2 from 15 to 0 (16 bits). Thus comparing the numerical value with those exponents using [[AND]] reveals the bit values as "1" for bits on or "0" for bits off as text.
: QB64 can use [[&B]] to convert the above [[_BIT]] values back to [[INTEGER]] or [[_BYTE]] values as shown below:
{{CodeStart}}'16 bit INTEGER values from -32768 to 32767