0% found this document useful (0 votes)
4 views

Week 2a - Information Processing in Humans and Machines

The document discusses the differences in information processing between humans and computers, highlighting human strengths such as common sense and emotional intelligence, and computer strengths like speed and accuracy. It explains fundamental concepts such as bits, data types, and various representations of integers, including signed and unsigned integers, as well as 2's complement. Additionally, it covers operations like arithmetic and logical functions, and introduces other data types such as floating point and ASCII code.

Uploaded by

owen chan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Week 2a - Information Processing in Humans and Machines

The document discusses the differences in information processing between humans and computers, highlighting human strengths such as common sense and emotional intelligence, and computer strengths like speed and accuracy. It explains fundamental concepts such as bits, data types, and various representations of integers, including signed and unsigned integers, as well as 2's complement. Additionally, it covers operations like arithmetic and logical functions, and introduces other data types such as floating point and ASCII code.

Uploaded by

owen chan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

CSIT123 Computing and Cyber

Security Fundamentals
Week 2: Information Processing in Humans and
Machines
Dr. Huseyin Hisil and Dr. Xueqiao Liu

Initially prepared by Dr. Dung Duong


Overview
● Information Processing in Humans
● Bits, Data Types, and Operations
Information Processing in Humans
● Human Strength
• Humans have common sense; multiple neurons and the brain has the
ability of self-processing.
• They can also think out of the box but sometimes take time to
recollection.
• Human brain receives inputs through senses such as hearing, sight and
detects patterns, abnormalities, and trends in visualization data. At the
same time, they can recognize facial expression, voice, and action.
• You can save unlimited information but takes time to recollect.
• Humans are still superior to computers in many ways as they can
perform tasks, make decisions, and solve problems based on
intelligence and life experiences.
Information Processing in Humans
● Computer Strength
• In computer, to process anything, it requires electricity.
• Computers require input and process at a faster speed.
• The computer supports a variety of input devices such as
keyboard, mouse, joystick, a microphone for voice input and
recognition, biometrics and scanners, etc. for communication, but
an input command is needed before you expect an output.
• Computer output device includes sound, display on the screen,
printouts when connected to external devices.
• Generally, the computers will not sleep like humans so they can
analyse, calculate and perform the task without tiredness.
• They are not affected or influenced by emotions, feelings, wants,
needs, etc.
Bits
● Two Conditions 0/1
• The flow of electrons are controlled by tiny components called
transistors. (Analogous to a On/Off tap to control water flow.)
• The presence of current flow is represented as 1 and the absence of as
0. This is called a bit, short for binary digit.
• If only two states in this binary system, how to represent large numbers
or more states?
• 1 wire for one bit, but we can combine multiple wires/bits.
• 2 bits can represent 4 potential states: 00, 01, 10, 11.
• 3 bits can represent 8 potential states: 000, 001, 010, 011, 100, 101,
110, 111.
• In general, k bits can distinguish at most 2k distinct items. Each pattern
of k bits is a code corresponding to a particular item or value.
Data Types
● What is data type?
• Number five can be denoted as 5. It can also be represented by holding
up one hand with all fingers extended. Romans used the character V. In
binary version, it is 101.
• A particular representation is a data type if there are operations in the
computer that can operate on information that is encoded in that
representation.
• Two types: 2’s complement integers (represent positive and negative
integers to perform arithmetic on) and ASCII codes (represent characters
on the keyboard to input to computer or display on computer’s monitor)
● What kinds of data do we encounter?
• Numbers: integer, float number, rational ...
• Texts: character, string …
• Visual signals: pixel, image, video …
• Auditory signals: sound …
Unsigned Integers
● What is an unsigned integer?
• As its name suggests, an unsigned integer has no sign (plus or minus)
associated with it. It just has a magnitude.
• E.g., it is used for identifying different memory locations.
• Decimal number 329 = 3 * 102 + 2 * 101 + 9 * 100
• Positional notation (a.k.a. Radix system): 3 is weighted 300, 2 is
weighted 20, and 9 is weighted 9 because of their different positions.
• 2’s complement representation: Instead of using decimal digits, we can
denote unsigned integers use with bits 0 and 1.
• Decimal number 5 = 1 * 22 + 0 * 21 + 1 * 20
• Now the base is 2 rather than 10. The left 1 is weighted 4 and the right
1 is weighted 1.
• In this binary positional system, how to represent a decimal number
329?
Signed Integers
● What is a signed integer?
• It is often necessary to deal with negative quantities as well as positive.
• We can take our 2k distinct patterns of k bits and separate them in half.
• E.g., 5 bits can denote 32 different patterns. Instead of representing unsigned
integers 0 - 31, it can denote positive integers: +1 to +15, -1 to -15, 0. Note:
we still have room for one more integer
• We would use exactly half of the 2k patterns to denote integers from 0 to 2k-1
- 1. All positive integers will have a leading 0 in representation. E.g., +15 is
denoted as 01111.
• How about negative numbers?
• Signed magnitude: use a leading 1 to signify a negative integer, e.g., -5 is denoted as 10101
• 1’s complement: flip every bit of its positive counterpart, e.g., -5 is denoted as 11010
• There are two representations for 0, i.e., +0 and -0. In addition, these above two ways both
require unnecessary cumbersome hardware to do addition, so computer designers choose
another way to simplify the circuit, i.e., 2’ complement.
2’ Complement Integers
● Four representations of integers

Image Source: https://www.amazon.com.au/gp/product/126042474X/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1


2’ Complement Integers

● Why do they choose 2’s complement?


• Given the representation of each positive number (X), design the
representation of its negative number (-X), such that X + (-X) = 0 with
easy addition circuit
• E.g., (+5) + (-5) = 0 and (+9) + (-9) = 0
00101 (5) 01001 (9)
+ 11011 (-5) + (-9)
00000 (0) 00000 (0)
• What is the representation of -9?
2’ Complement Integers
● Can you summarize the 2’s complement representation from
the above two examples?
• If X is a positive or zero, use its binary representation, then fill in
remaining blanks with leading 0s from the most significant bit
• If -X is a negative, find X’s 2’s complement representation, flip every bit,
and add 1
• Q: What is the 2’s complement representation for -9?
● What is the range of a k-bit signed integer?
• From -2k-1 to 2k-1-1 01001 9
• The most significant bit denotes parity flip every bit
10110
+ 1 add 1
10111 -9
Covert 2’s Complement to Decimal
● How to convert 2’s complement to decimal?
• The most significant bit denotes the parity
• If it is positive or zero (the most significant bit is 0), compute the
weighted sum
• If it is negative (the most significant bit is 1), subtract 1 from the
remaining, flip each bit, compute the weighted sum, and put a leading –
• E.g., 5-bit 2’s complement signed integers 00010 and 11010
00010 = 0 * 23 + 0 * 22 + 1 * 21 + 0 * 20
=2
11010 11001 00110
= - (0 * 23 + 1 * 22 + 1 * 21 + 0 * 20)
= -6
Covert Decimal to 2’s Complement
● How to convert decimal to 2’s complement?
• Find its magnitude, assign magnitude to quotient q
• Divide the q by 2, fill in the binary representation with the remainder r
(from the least significant bit to higher significant bit), repeat this step
until the q is 0
• Fill in the remaining bits with 0 if it is positive or zero; otherwise
compute its 2’s complement
• E.g., assume k = 5, X = 13, result is 01101; if X=-13, result is 10011.
2|13
2|6 q = 6, r = 1 1
2|3 q = 3, r = 0 01
2|1 q = 1, r = 1 101
0 q = 0, r = 1 1101
Operations: Arithmetic
● Addition
• Use the larger bit length to represent both as 2’s complement integers
• Conduct binary addition or subtraction
• Ignore the carry out
• E.g., assume k = 8, X = 100, Y = -16, X + Y = 84.
01100100 100
+ 11110000 -16
01010100 84
● Subtraction
• Negate subtrahend and conduct addition.
• E.g., assume k = 8, X = 100, Y = 16, X - Y = X + (-Y).
Operations: Arithmetic
● Sign Extension
• replicate the most significant bit (the sign bit):
• E.g., given 4-bit representation, get 8-bit representation

0110 6 1010 -6
00000110 6 11111010 -6
● Overflow
• If operands are too big, the sum cannot be represented as an n-bit 2’s comp
number.
01000 (8) 11000 (-8)
+ 01001 (9) + 10111 (-9)
10001 (-15) 01111 (+15)
• signs of both operands are the same, and sign of sum is different.
Operations: Logical

● AND, OR, NOT, and Exclusive-OR


• Two states - use one bit to represent: TRUE=1, FALSE=0
• Represent as binary
• Follow the truth table below bit by bit

Image Source: https://www.amazon.com.au/gp/product/126042474X/ref=ppx_yo_dt_b_asin_title_o05_s00?ie=UTF8&psc=1


Other Data Types
● Hexadecimal Notation
• Use fewer digits to write binary (base-2) number as hexadecimal (base-
16) numbers
• Conversion between from/to Binary

Image Source: https://www.geeksforgeeks.org/convert-binary-number-hexadecimal-number/


Other Data Types
● Fractions and Fixed Point
• Use a “binary point” to separate positive from negative powers of two,
similar to “decimal point”, align binary points during computation
• Apply 2’s comp addition and subtraction
2-1 = 0.5
2-2 = 0.25
2-3 = 0.125

00101000.101 (40.625)
+ 11111110.111 (-1.125)
00100111.100 (39.5)
Other Data Types
● Floating Point
• Represent very large and very small numbers with a lower precision
• As large as 6.023 x 1023 (79 bits) and as small as 6.626 x 10-34 (110 bits)
• Use scientific notation”: (-1)s x 1.m x 2e-127
• Separately represent m (fraction/mantissa), e (exponent), and s (sign).
• IEEE 754 Floating-Point Standard (32-bits/Single Precision):

Image Source: https://www.geeksforgeeks.org/ieee-standard-754-floating-point-numbers/


Other Data Types

● Floating Point (-1)s x 1.m x 2e-127


• E.g., 85.125

Image Source: https://www.geeksforgeeks.org/ieee-standard-754-floating-point-numbers/


Other Data Types
● ASCII Code
• Represent 128 (control, printable, and extended) characters to 7-bit
codes

Image Source: https://www.vlsifacts.com/ascii-code/


Other Data Types
● Texts/Strings
• Sequence of characters, terminated with NULL (0)
• No hardware support as binary
● Images
• Array of Pixels
• monochrome: one bit (1/0 = black/white)
• colour: red, green, blue (RGB) components (e.g., 8 bits each)
• no hardware support in general-purpose processors
● Sound
• Sequence of fixed-point numbers

Image Source: https://www.geeksforgeeks.org/convert-binary-number-hexadecimal-number/


Reference
● Human Vs Computer, INFORMATIONQ.
https://informationq.com/human-vs-computer/
● Patt, Y.N., 2020. Introduction to computing systems from bits and gates
to C/C++ and beyond. McGraw-Hill Higher Education.
● IEEE Standard 754 Floating Point Numbers, Geeks for Geeks.
https://www.geeksforgeeks.org/ieee-standard-754-floating-point-
numbers/

You might also like