An array is a set of sequentially indexed elements
having the same type. Each element of an array has a unique index number that
identifies it. Changes made to an element of an array do not affect the other
elements.
The index must be a numeric constant, a byte, an integer , word or long. The
maximum number of elements is 65535. The first element of an array is always
one. This means that elements are 1-based.
Arrays can be used on each place where a 'normal' variable is expected.
Important |
The number of elements must be known during compile time. |
Defining an array with 10 element
Dim A(10) As Byte 'correct
Const Cl = 10
Dim B(cl) As Byte 'correct
Dim Vl As Byte
vl = 10
Dim C(vl) As Byte 'not allowed
The book contains some not allowed array definitions
(look to MEAN.BAS). With the used compiler version that definitions worked because
no other definition of variables followed.
The actual compiler version detects an access to a variable defined in the third
way!
2001-10-06
S. 73 4.3 Variable
In the table long and single have the sam format. That's not correct.
BASCOM-AVR Help shows the correct formats and ranges.
• | Bit (1/8 byte). A bit can hold only the value 0 or 1. A group of 8 bits is called a byte. |
• | Byte (1 byte). Bytes are stores as unsigned 8-bit binary numbers ranging in value from 0 to 255. |
• | Integer (two bytes). Integers are stored as signed sixteen-bit binary numbers ranging in value from -32,768 to +32,767. |
• | Word (two bytes). Words are stored as unsigned sixteen-bit binary numbers ranging in value from 0 to 65535. |
• | Long (four bytes). Longs are stored as signed 32-bit binary numbers ranging in value from -2147483648 to 2147483647. |
• | Single. Singles are stored as signed 32 bit binary numbers. Ranging in value from 1.5 x 10^–45 to 3.4 x 10^38 |
• | Double. Doubles are stored as signed 64 bit binary numbers. Ranging in value from 5.0 x 10^–324 to 1.7 x 10^308 |
• | String (up to 254 bytes). Strings are stored as bytes and are terminated with a 0-byte. A string dimensioned with a length of 10 bytes will occupy 11 bytes. |
S. 77 4.5 Gleitkommaarithmetik
There are some failures in the table below. For further explanations have a look into BASCOM-AVR help please.
Floating Point Number | S | E [hex] | M [hex] | 1.M [bin] |
1.234 | 0 | 3F | 9D F3 B6 | 1 .00111011111001110110110 |
12.34 | 0 | 41 | 45 70 A4 | 1 .10001010111000010100100 |
-12.34 | 1 | C1 | 45 70 A4 | 1 .10001010111000010100100 |
http://zogg-jm.ch/IEEE_754_Umwandlung_Gleitkomma_zu_32_u_64_Bit.html
2013-12-14