Section 4.7
4 Data Representation
4.7 Range And Accuracy
4.7.1 Integer Range
QuickBASIC uses two bytes to store integers. As it uses the Two's Complement
system, the integer range is:
Largest Positive Number = 0111 1111 1111 1111 = 32, 767
Largest Negative Number = 1000 0000 0000 0000 = 32, 768
4.7.2 Normalised Floating Point Numbers
Using a 6-bit mantissa and a 4-bit exponent.
|
Positive
|
Negative
|
Largest Magnitude
|
0.11111 × 20111
= 12410
|
1.00000 × 20111
= -12810
|
Smallest Magnitude
|
0.10000 × 21000
= 0.00195312510
|
1.01111 × 21000
= -0.002075195312510
|
Representation Of Zeros
The number 0.00000 × 20000 is not normalised and does not exist in
this system.
Zero is usually represented by the smallest possible number and this number is
left from the range.
4.7.3 Excess Notation
Exponents of floating point numbers may be represented in excess notation
rather than Two's Complement.
A 7-bit Two's Complement exponent will go from:
-6410 = 1000 000
63 = 0111 111
If we add 64 to this in binary it can be coded as a positive value (0 to 127).
This is called Excess 64 notation because a value of 64 has been added.
To interpret such a number we subtract 64 from it.
For an eight bit number, we would use Excess 128 notation.
4.7.4 Accuracy And Errors
Floating and fixed point numbers will be accurate to the smallest number they
can represent.
Round-Off Errors
Often we cannot represent a denary fraction exactly even if we allow many bits
in memory. Therefore the number stored is "rounded off" to the closest possible
binary equivalent.
Truncation Errors
Often, in either floating or fixed point systems, results are calculated with
too many places of accuracy to be represented. We get this type of error when
traling bits are truncated to fit the result in the memory location available.
Overflow
A computational process produces a result so large that it cannot be
represented.
Underflow
A result is produced that is smaller in magnitude than the smallest number that
can be represented.