Docsity

Number Representation: Understanding Binary, Bit Patterns, and Floating Point Notations, Slides of Aeronautical Engineering

Toggle sidebar
bg1
Lecture C5: Number representation
Please take a look at the handput "Number Systems" which has answers to lots of the muddy card
question's from this lecture.
Response to 'Muddiest Part of the Lecture Cards'
(53 respondents, out of 67students)
1) Why is it important to know binary? (and similar questions) (7 students)
Binary is crucial because 0’s and 1’s are the only language that a computer understands. All your high
level languages are transformed into machine language (fixed patterns of 0’s and 1’s). We will look at a
simple machine language in upcoming lectures.
2) How to represent numbers w/ bit patterns? (1 student)
The representation schemes such as ASCII, Hex, Binary coding, Float-point representations, all provide
means of representing numbers as bit patterns.
3) How do we know what format of binary string is being used, how do we know which is best to
employ? (and similar questions) (4 students)
Good question. There are number of ways (I am sure you can come up with your own scheme) of
representing a number in binary representation. There are standardization committees that decide which
formats are used and these are agreed upon universally.
4) On slide number 2 in today's lecture, you show that 101101 = 37, but doesnt that equal 45? (1
student)
It sure does! There is a typo in the figure I coiped from Brookshear (Figure 1.15). 101101 equals 45.
5 ) How do you store values w/ base 10 using ASCII? (1 student)
In ASCII, we represent each symbol by an integer value. For example ‘a’ is using decimal number
system = 97 or using hexadecimal number system 61.
So the bit pattern to represent ‘a’ = 01100001
docsity.com
pf3
pf4

Partial preview of the text

Download Number Representation: Understanding Binary, Bit Patterns, and Floating Point Notations and more Slides Aeronautical Engineering in PDF only on Docsity!

Lecture C5: Number representation

Please take a look at the handput " Number Systems " which has answers to lots of the muddy card

question's from this lecture.

Response to 'Muddiest Part of the Lecture Cards'

(53 respondents, out of 67students)

  1. Why is it important to know binary? (and similar questions) (7 students)

Binary is crucial because 0’s and 1’s are the only language that a computer understands. All your high level languages are transformed into machine language (fixed patterns of 0’s and 1’s). We will look at a simple machine language in upcoming lectures.

  1. How to represent numbers w/ bit patterns? (1 student)

The representation schemes such as ASCII, Hex, Binary coding, Float-point representations, all provide means of representing numbers as bit patterns.

  1. How do we know what format of binary string is being used, how do we know which is best to employ? (and similar questions) (4 students)

Good question. There are number of ways (I am sure you can come up with your own scheme) of representing a number in binary representation. There are standardization committees that decide which formats are used and these are agreed upon universally.

  1. On slide number 2 in today's lecture, you show that 101101 = 37, but doesnt that equal 45? ( student)

It sure does! There is a typo in the figure I coiped from Brookshear (Figure 1.15). 101101 equals 45.

5 ) How do you store values w/ base 10 using ASCII? (1 student)

In ASCII, we represent each symbol by an integer value. For example ‘a’ is using decimal number system = 97 or using hexadecimal number system 61. So the bit pattern to represent ‘a’ = 01100001

  1. 110 +100=010 = 2? (1 student)

If you have only three bits to represent the number, the ‘ 1 ’ is lost (this phenomenon is called overflow).

  1. So, 1's complement is not used? (1 student)

1’s complement is used. You need to compute the 1’s complement before you can compute the 2’s complement. The handout on number systems has a detailed discussion on the topic.

  1. 2's complement? (1 student)

The algorithm for computing 2’s complement is as follows:

  • Compute the 1’s complement
  • Add 1

Note that in 2’s complement notation, the bit patterns are unique. There is no possibility of the numbers being represented twice.

  1. In 2's complement, is the first bit only the sign bit or is it used? (1 student)

The process of converting the number into 2’s complement representation causes the most significant bit to become 1. It is not explicitly set. You do use all the bits to represent a number.

  1. Is the MSB still a sign indicator in 2's compliment? (1 student)

Yes, but it is not explicitly set that way.

  1. Using 8 bits and 2's complement method to represent negative numbers, you can only represent values between 127 and -128? (1 student) Yes

  2. Excess notation, magic number? (18 students)

When using the process defined in Brookshear, there is no loss in precision. Whereas when we do scientific normalization, the 1 can be omitted safely and we gain an extra bit in precision.

  1. For negative floating points, we only do 2's complement for the number on the left of the decimal, right? (1 student)

When you are representing floating point numbers, you don’t use two’s complement notation at all. You will directly convert the number into the floating point number format using the brookshear algorithm and use the sign bit to represent whether the number was negative or positive.

  1. When I perform calculations on my computer I never get errors because of overflow of a number. Do computers use more than 8 bits for numbers? If computers are so powerful now, do we have to worry about overflow for such small numbers? (and similar questions) (5 students)

Good question. When you program yourself, it is critical to take care of both overflow and underflow errors. One of the causes of the Therac-25 accidents was an overflow. The counter would increment the number by 1 every time radiation therapy was performed. When the count reached the maximum number, adding 1 caused it to be reset to zero, dosing the patient with a toxic amount of radiation. You can represent numbers as sequences of bytes. Typically, an integer is 16bits, a single-precision floating-point number is 32 bit and a double-precision floating-point number is 64 bits. The representation of numbers as sequences of bytes, brings up the issue of “endian” representation. (For the roots of why word endian is used, see the handout on number systems).

The computer has no cognitive capabilities – they cannot think on their own. What a computer can do (and very well at that) is do what it is instructed to do – really fast. It cannot understand the nuances of communication that way human beings can. So the quality of your program determines whether the computer performs the operation correctly or not. The ability to think is what makes even the youngest child smarter than a computer.

  1. Can we practice number transformation? (2 students)

Please attend recitation, talk to TAs, or let me know if you want more examples than those shown so far.

  1. "No mud" (7 students) Good :o)