141-data-representation Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Data Types

A
  • Forms of data stored and used in computer programs.
  • Different data types take up different amounts of memory.
  • The correct data type should be used to optimize program performance.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Main data types include: integer, real/float, boolean, character, and string

A
  • Integer - whole numbers without a fractional part
  • Real - numbers that may or may not have a fractional part (Float is a subtype of real numbers and represents a number with a floating decimal point)
  • Character - single symbol used by a computer, including alphanumeric
  • String - collection of characters, used for storing text and phone numbers
  • Boolean - only two truth values (true or false), associated with logic and Boolean algebra.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Primitive data type:

A
  • Basic data type provided by programming language
  • Foundational building block for more complex data types
  • Number, type, and name of primitive data types vary between programming languages
  • All programming languages support primitive data types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Casting data types

A

converting one data type to another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why is data stored in computers in a binary format?

A
  • circuits only need to check for two states: electricity flowing or not flowing, on or off, and 1 and 0
  • less precision is required to detect one of two states e.g during data transfer
    -compatibility with existing systems
  • simpler to build electronic devices/electrical components that only use two states
  • additional states would make the components more difficult to build and more prone to error.
  • bit patterns used to represent instructions and various forms of data e.g character sets, images
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Bit

A

binary digit that can have two values: 0 or 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Overflow Error

A
  • number cant fit into one byte/whatever and is too big for the register
  • extra carry/bit
  • results in a loss of accuracy as bits on the left are removed.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Hexadecimal

A
  • base 16, made up of 4 bits per hex digit.
  • 1 hexadecimal = 1 nibble.
  • used in defining colours in graphics software, representing MAC addresses and memory addresses, checksums.
  • straightforward to convert between binary and it, shorter to remember, quicker to enter, less susceptible to error, easier/quicker to communicate/write/read with
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Sign and Magnitude

A
  • First number represents sign. 1 is negative and 0 is positive.
  • Largest positive number in an 8-bit binary using sign and magnitude is +127.
  • Can represent negative numbers from -1 to -127.
  • Simple and easy to understand. Allows for straightforward representation of both positive and negative numbers.
  • Two representations of zero (+0 and -0). More complex when doing arithmetic involving negative numbers. Waste of one bit
  • Used when there is no need to perform complex arithmetic with negative numbers, and simplicity is more important.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

One’s Complement

A
  • Easy to implement. Same magnitude bits are added easily.
  • Has two representations of 0 (-0 or 0). there cannot be a negative zero, so this ambiguity can cause problems in some computations and when with all bits set as 1 or 0 . complications with rounding, overflow and precision errors
  • Complexity: requires additional logic and operations to handle negative numbers, makes programming more complex and time-consuming.
  • Used in some computer architectures, but generally not preferred over two’s complement.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

ones complement method

A
  • Flip all the bits of a negative binary number and result is the positive version, and vice versa.
    E.g 0101 is 5, 1010 is –5.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Two’s complement

A
  • Only one representation of zero. Simpler and more efficient for arithmetic operations on negative numbers. Simplifies implementation.
  • most significant bit as a negative value number
  • hardware support for negation. complement operation is a bit-wise operation, faster than division/multiplication, etc.
  • A negative number has one more negative value than a positive number. e.g -128 to 64 for 8 bits
  • Almost universally used in modern computer systems.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

twos complement method

A

First number is a negative number. E.g 1110 would be -8 + 4 + 2 = -2.
Adding 1’s to the number front will not change the value.
To change from positive to negative, flip all the bits and add 1 (binary version so 0000 0001).
Positive numbers always start with a 0, while negative numbers always start with a 1.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

fixed-point binary

A
  • stores fractions with a fixed position of the point on the number line: fixed number of bits for integer and fractional parts, with a fixed decimal point position and scaling factor.
  • range of numbers that can be stored is limited due to some positions being used for the fractional part.
  • e.g. 6-bit fixed-point number with 8 fractional bits might represent the value 1.5 as 0000 0001 0100 0000, first 8 bits’ the integer part and the remaining 8 bits’ the fractional part.
  • simpler but less flexible than floating-point. Do not need to be normalized, unlike floating-point numbers.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

normalisation

A
  • Representing a floating-point number in a standard form.
  • involves adjusting it to start with 01 for positive or 10 for negative
  • to ensure precision in a given number of bits and that there is only one way of representing any given number, which is important for consistency and storing numbers to the highest possible degree of accuracy
  • Necessary for correct arithmetic operations and comparisons between floating-point numbers.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

representing fractional numbers using floating-point binary method

A

e.g 4 bit mantissa and 4 bit exponent
split into mantissa and exponent, work out exponent
0111 0001
floating point always starts at 0.111
E=1. When E is positive, move right from point, when it’s negative move left
moves one space
01.11
1+0.5+0.25= 1.75
if mantissa doesn’t start with 01 or 10, normalise it first. by working out what the number is first ^ and then making it so it starts with 10 or 01

17
Q

floating-point binary:

A
  • number of bits allocated to the integer and fractional parts varies depending on the size of the number.
  • number is represented as a mantissa , and an exponent (a binary integer) specifies the position of the decimal point.
  • allows a wider range of values to be represented with higher precision, but at the cost of greater complexity and slower computation.
18
Q

Increasing the mantissa size:

A
  • Increases precision of floating-point number, more precise fractions can be represented, less round-off errors so more accurate calculations
  • requires more memory and computational resources to store and perform operations on the number
19
Q

Increasing the exponent size:

A
  • increases the range of numbers that can be represented, allowing for larger and smaller numbers
  • But reduces precision of number, as same number of bits are now being used to represent a wider range of values.
  • require more memory and computational resources to perform operations with the number
20
Q

Bitwise Shifts:

A
  • shift involves moving all of the bits in a binary number a specified number of places to the right/left, adding a number of leading or trailing 0s, and 1s for negative.
  • Logical binary left shift of 1 multiplies denary number by 2, while right divides denary number by 2.
  • arithmetic left shift of 1 shifts everything to the left which multiplies it by 2, while a right shift of 1 fills in the gaps after the shift with the previous MSB value. better for two complements as the sign is always retained.
21
Q

Bitwise Masks:

A
  • applied to binary numbers by combining them with a logic gate.
  • allow us to manipulate bit patterns by applying masks and make use of logical operators such as AND, OR, XOR.
  • AND extracts a subset of the bits in the value,
  • OR sets a subset of the bits in the value,
  • XOR toggles a subset of the bits in a value.
  • used in routing traffic on a network by examining the network ID.
22
Q

character set

A
  • standardized collection of characters that includes the range of symbols, numbers, and letters that can be represented and understood by a computer.
  • Each character in a character set is assigned a unique character code in binary.
  • Using the correct character set and encoding is important to ensure data is displayed and processed correctly.
  • Character encoding is the method used to translate character codes into binary
  • Examples of standards in use include character sets for correct interpretation and display of text data.
23
Q

ASCII
(American Standard Code for Information Interchange)

A
  • 7-bit character set, supports 2^7 combinations/characters (128).
  • Limited to representing only characters used in the English language and lacks support for many characters used in other languages
  • Widely supported and used in older computer systems and applications
24
Q

Extended ASCII

A
  • 8-bit character set, can represent 256 characters, including European symbols and other languages. For a specific group of languages, different variants
  • Limited to specific regions or languages, with different versions of the standard created for different languages and hence not suitable for representing characters from multiple languages or regions
25
Q

Unicode

A
  • multilingual and universal character set that can represent over 1 million characters, with the ability to represent any character used by any human language.
  • uses 16 or up to 32 bits to encode characters, with variable-length encoding.
  • characters can be encoded and displayed correctly regardless of the language/region its used in.
    –increased storage requirements - contents may look identical but text file stored using Unicode takes up more space one stored in ASCII.
  • used in modern computing systems and applications to support multilingual text data, including web pages and databases.
26
Q

What are the problems with storing characters in binary?

A
  • take up more space than ASCII
  • writing in 24 bits is slow, cumbersome, and prone to error, so hexadecimal is used instead to make it easier to refer to a particular character and its code.
27
Q

Multiplying numbers using shifts and addition (binary)

A

Multiple 6 by 6 by using shifts and addition

0000 0110 = 6

0001 1000 x4

0000 1100 x2

Add the x4 and x2 together to make x6
0001 1000 +
0000 1100
————-
0010 0100

32+4-=36

28
Q

Circular shifts

A

it just loops around