Lecture C4: Strings, IF-statement, bits and bytes
Response to 'Muddiest Part of the Lecture Cards'
(63 respondents, out of 72 students)
What is Little/Big Endian?
I did not have time to cover that in class today. Will on Friday.
Endianness refers to which bytes (1 byte = 8 bits) are most significant in a multi-byte data type. In a big
endian machine, the leftmost byte (the one with the lower address) is the most significant. In a little-
endian machine, the righmost byte is the most significant. For example the 32 bit hexadecimal number
16#ABCDEF42# will on a big-endian machine be stored in 4 consecutive bytes in the following order:
AB CD EF 42. The same 32 bit number would on a little-endian machine be saved in the following byte
order: 42 EF CD AB. Examples of little-endian machines are the Intel x86. Examples of big-endian
machines are: Motorola 68k and the PowerPC.
Could we get more practice using hexadecimal code?
Yes, absolutely! Maybe already in tomorrows recitation.
What is FOR?
Ada provides the FOR statement for definite iteration. Definite iteration is where the set of actions is
performed a known number of times. The number might be determined by the program specification, or
it might not be known until the program is executing, just before starting the iteration. The FOR
statement will be covered in later lecture.
B inary numbers only use ones and zeros as their numbers. A binary number can be repsesented by any
set of bits (binary digits). We will see example of this in recitation tomorrow. Just as an example, the
decimal numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 are represented using 4 bits in the following way:
0001, 0010, 0011, 0100, 0101, 0110, 0111, 1000, 1001, 1010, 1011, 1100. Arithmetic in binary is much
like arithmetic in other numberal systems:
0 + 0 = 0
0 + 1 = 1
1 + 0 = 1
1 + 1 = 10 (the 1 is a Carry/overflow)
Concatenation of strings
(and other Stirng questions) (5 students)
The string concatenation operator
applied to 2 strings S1 and S2, concatenates, or "pastes together",