Representing Data Flashcards
In what Language do computers operate in
Binary, 0s and 1s , everything we need to represent must be transformed in these 0s and 1s
What is string concatenation
String contentation occurs when you use an addition operator between two strings to combine them into one.
How does the addition operator act in different ways
It can perform addition on strings by combining them directly or it can computer the sum of numbers.
Within binary what do the 1 and 0 represent
1 represents that an electrical signal has been read or transmitted whereas a 0 is the privation of an electrical signal
What is a 64 bit computer
When the computer handles strings of 64 bits for transferring data. This results in double transfer speeds than previous 32bit machines
How many bits did computer utilise in the 1980s when Sonic was released
8 bits
What are the basic types of data supported by programming languages
- Integers - whole numbers
- Decimals - fractions
- Strings - sequences of characters
How many bits are utilised to represent a character in a string
8 bits represenmting 256 different chracters
* The ASCII dataset uses 8 bits to represent 256 different character
What is unicode
An alternative to ASCII useful for other languages and supports more than 8 bits per character allowing much more options
What is meant by a denary base number system
A number system that is commonly utilised by humans such that a number 123 = 1 x 100 + 2 * 10 + 3 * 1, it utilises 10^n+1 to move a position with 10 combinations per space
What is a base 2 number system
A base 2 number system utilises 2 possibilities per space and 2^n+1 to move each position up. Such that 0110 = 6
What are some benefits of utilising binary in a computer system
Much hardware that is used with computers such as HDD and CDs that engrave pits to represent 1 and absence of for 0.
Similarly systems experience a lot of noise which can alter the states, if there are more states this will result in a higher likelihood of errors
What is the range of an 8 bit number system
0 - 255
What is hexadecimal notation
It is taking each group of four bits and representing it with a single digit
Hexadecimal
0000 0 0
0001 1 1
0010 2 2
0011 3 3
0100 4 4
0101 5 5
0110 6 6
0111 7 7
1000 8 8
1001 9 9
1010 10 A
1011 11 B
1100 12 C
1101 13 D
1110 14 E
1111 15 F
How do we represent negative numbers in sign bit representation
Utilising the left most bit as a sign bit, 0 indicated positive and 1 indicated a negative.
What is the sign magnitude representation
It utilises the left most bit as a sign 0 being positive and 1 being negative, the rest of the bits represent their usual value
What are the benefits of using a sign magnitude bit
Allows us to see if a number is negative or positive in value by evaluating the left most bit
What happens to the range of bits when implementing sign magnitude bits
overall representation of numbers remains the same however two expressions for 0 and there is positive number impacted
2^8 = 0 -255 = 256 nums
2^8 = 2^8-1 = -127 – 127 = 256 nums
as 1 bit is used for sign magnitude
What is a negative implication of using the sign magnitude representation
There are two representations of zero such that positive 0 = 0000 and negative 0 would be expressed as 1000.
Therefore the n bit representation has only ((2^n) -1) different values
What is Twos complement
A more modern way of representing negative integers in a computer system such that the left most bit on represents a negative minimum value
What is the range in twos complement
The range in twos complement would be (+2^(n-1) -1) to (2^(n-1))
such that in a 4 bit system with twos complement the range would be from 7 to -8
What is overflow error?
In the computation of bit strings often there is a remainder bit that is ignored, skewing the result of the calculation.
What are floating point numbers?
They are a solution to the problem that computers faced with expressing real numbers, that is continous data expressed in a limitted descrete format ignoring recurring decimals such as 0.3. These finite approximations are utilised instead.
How will there be infintely many non represent able reals between any two floating point numbers
take some x and x’ such that they differ by the smalles amount allowed in our systems representation. Between x and x’ there will be a y which is a non representable real. between x and y there is another z and between y and x’ another a. This will result in a recursive issue and an infintely amount of on representable reals between two floating point numbers
What is a rounding error
When utilising floating point numbers there is a small remainder often given by the computer rounding due to the previous issue that it cannot truly represent real numbers. If the rounding error becomes too noticeable due to multiple computiations we may actually recieve an unnacceptable result as a computation
What is a numerically unstable calculation
When the rounding errors only affect the last few decimal places they can begin to grow during sequences of calculations resulting in the expected result being skewed
Why would it be an issue to use floating point data types in an accounting software? What alternatives can we pose
The rounding error, numerically unstable calculations from floating point numbers can result in a level of uncertainty being introduced when it is unnecessary.
As an alternative we may introduce pennies stored as integers, at the end we can divide our results by 100 to limit uncertainty
Explain this error posed by the program?
First number? 0.1
Second number? 0.2
Sum is 0.30000000000000004
As the computers do not have an exact representation of 1/10 it will approximate it to the closest value, in this case the value approximated too carries small decimal value which is expressed in the final calculation.
What is the string data type in java
It is an array of characters
Boolean values
True or False values often represented as a single byte, the smallest sequence of bits that can be fetched from RAM with the quickest efficiency
Pigeonhole model of RAM
It is that the slots within the RAM act as slots for storing single bytes that are numbered and locations are noted to fetch and control what is transmitted to and fro them. Each pigeonhole is allocated a permanent number called its address
What is a variable declaration
It is denoting the name and datatype of the variable before it is utilised
What is a valid identifier
It is the name of the variable and must fit the code that is start with a letter. idenitifiers in java are case sensitive. If more than two words are utilised the second word and subsequent words are capitalised.
What is the convention for writing class names?
That they begin with a capital letter
What occurs at the declaration stage of a variable when denoting the variables type
It creates a box large enough to store values of the given type. And associates the idenitifier with the box storing a given value.
What is the assignment stage of a variable
It is assigning a value of the given data type into the box we initialising, finally this process is known as intialisation, when the variable has been declared and assigned
Operator precendence
It is the idea that some operators have precedence in performing over others such that 2 + 5 * 2 = 12 and not 14.
What is the general convention when specifying order of calculations in java
Due to the 14 different operator precendence levels it is preferablet to utilise brackets
How can you compare the lexicographical ordering of two strings in java
Utilising the first.compareTo(second) whicil will return a negative int if first is less than second, postive if greater and zero if theyre the same
What is the difference between | and || in java
acts as a logical OR the || double stroke version represents a short circuit or where the left statement is evaluated first
what is the difference between & and && in java
the && acts similarly as a logical AND with a short circuit feature evaualting the left statement first
how does a conditional triadic operator work
predicate expression ? then expression: else expression
int b = 20 + ( (a < 0) ? -a : a); intialise b as twenty plus some conditional value
What is the result of the assignment operator
It is that the value has been assigned
What associative are the assignment operators
They are right associative which means that a string of assignments is evaulated right to left not left to right.
int a, b, c;
a = b = c = 35;
(a = (b = (c = 35)));
What is a side effect of an expression
A side effect of an expression is that it appears to be other than it is , such that if we assign a = a +1 we are not mathemetically asserting a is itself plus 1 but a is assigned to the value of (a +1) which is 36 such that a = 36.
What are op and becomes operators
They are methods of simplifying recalling a variable when assigning it a value
Incrementing have special operators that are included within java
++ – are allowing incrementation and decrementation
What is meant by prefix and postfix form
the same operators will act differently dependant upon the position of the operator
++ and –
How does the prefix form work as
It will