Skip to content

DA3. Data Types

Question 1: Big and Little Endian

Assume that you are the instructor. Prepare a short written lecture that describes Big Endian, Little Endian and the advantages and disadvantages of each approach.

  • Everything is stored in memory as a sequence of words, where a word is a fixed number of bytes, e.g., 4 bytes (32 bits) or 8 bytes (64 bits).
  • We as humans think of numbers in base 10, but computers store numbers in base 2 (binary).
  • Humans used to write numbers from left to right, where the most significant digit is on the left and the least significant digit is on the right.
  • For computers, there is no left or right, so we need to define a convention for storing numbers in memory (Curren, 1994).
  • Big Endian stores the most significant byte is stored in the smallest address (left to right).
  • Little Endian stores the least significant byte is stored in the smallest address (right to left).
  • There is no advantages or disadvantages to either approach, it depends on the user intuition and preferences.
  • However, companies have already taken sides, for example, Intel uses Little Endian and Motorola uses Big Endian (Oracle, n.d.), and in such a case, it is not a choice anymore, it depends on the hardware.
  • However programs are smart enough to handle both cases, and they can convert from one to another as needed.

Question 2: Overflow

In this unit, we discussed integer data types and integer math. One of the concepts that we learned about was an overflow. As part of your response describe what an overflow is an how it occurs. Conduct research on the internet and based upon your research, describe some of the problems that overflow causes there are many but one area that you should research (among others) is the concept of integer based security attacks.

  • An overflow happens when the result of an arithmetic operation is too large to be represented in the available memory word size; that is, when you need to carry a bit to the left, but there is no space for it, aka, the number is too big to be represented and the result is larger than the maximum value that can be stored in the memory word size.
  • Nowadays, softwares (including operating systems) are smart enough to handle overflows, and they can detect and handle them.
  • Memory words today are large enough to handle most of the operations, and if not, the software will throw an exception.
  • However, there are security risks associated with overflows, one of them is the buffer overflow attack where the attacker tries to cause an overflow in memory that allows them to access unauthorized memory locations, where they can execute malicious code.
  • The other main issue associated with overflows, is that they give a wrong result, so even if the software can handle the overflow, the result will be wrong.

References

3 + 6 + 9 + 12 + 15 + 18 + 21 + 21 + 24 + 27 + 30 + 33 + 36 + 39 + 42 + 45 + 48

16/2