A-Level Computer Science Revision Guide: Data Types & Conversions
Elevate your exam preparation with this detailed A-Level Computer Science revision guide on Data Types. This material provides in-depth explanations of primitive data types, conversions between binary, denary, and hexadecimal, a...
Computer science—A Level—Topic 10 Data Types
Primitive data types What is meant by the term ‘data type’?
The basic data types provided by a programming language as building blocks. A data type is like a class which different types of data fall into,
this is because different types of data can take up different
amounts of memory therefore to make sure a program is opti-
mised, we make sure we assign the correct data type to a certain
piece of data.
Conversions between Denary, Hex and Binary
•A Binary digit (Base 2) simply contains 0’s and 1’s suggesting there are
only 2 possible states.
•A Denary digit (Base 10) contains numbers 0-9.
Representing negative binary numbers •A Hex digit (Base 16) contains numbers 0-9 then the letters A-F.
•Sign & magnitude—a computing method of storing strings/binary
into negative values, it works by making the MSB into a sign bit <- Weight line
where 0 = positive and 1 = negative.
Denary → Binary
1.First draw the binary weight line.
2.Start from the MSB and place a ‘1’ under the first bit smaller than the
denary value and then take away the bit value from the denary value to
get new denary value.
•Twos complement—a computing method of storing floating
point real values (+ and -) where the MSB is the relative MSB but 3.Put ‘0’ under the bits that have higher values than the denary value.
negative. Denary → Hex
1.Convert the Denary into an 8-bit binary number.
2.Split the 8-bit binary number into 2 nibbles (4 bits).
3.Using a weighing line that goes up to 4 bits for each, convert each nibble
into hexadecimal values.
Binary → Denary
Positive → Negative using twos complement 1.Construct a weighing line.
1.First convert the positive denary value to binary. 2.Put the ‘0’s and ‘1’s into their corresponding positions and then add the
2.Starting from LSB, copy each digit until you reach the first ‘1’. values that the ‘1’s are underneath.
3.Beyond this point, swap all the 1’s and 0’s vice versa. How are numbers stored in memory?
In memory (RAM), capacitors either hold a charge(1) or don’t (0), it has two
Adding and subtracting binary numbers possible states which is how binary works, therefore data like numbers are
stored in binary values to represent the two states.
•In binary: 0+0 = 0 , 1+0 = 1, 1+1=1 (carry 1), 1+1+1=1 (carry 1). What examples are there where working with large binary numbers is a
problem, and what is the solution?
When storing many different colours of an image, as there is 16+ million
colours binary values would be immensely large however due to hexadeci-
mal being able to represent these in a more compact and human-friendly
way as we can represent an 8-bit binary in 2 bits.
Character sets
A character set is a defined list of characters recognised by the computer
hardware and software, with each character being represented by a single
number (in binary).
•Each character has its own unique binary codes.
An overflow error occurs when a value greater than 255 is cal- •They are agreed standards for referring to all the characters a computer
culated after binary addition using 8 bits. can use.
•To subtract binary numbers, convert the number we want to 1.ASCII ( American standard code information interchange ): ASCII codes
subtract into its twos complement form and follow the same bi- use 7-bits giving 32 control codes and 96 displayable characters.
nary addition rules. 2.Extended ASCII : Uses 8-bits which made it possible to store foreign char-
acters and a limited number of graphical symbols.
3.Unicode—uses 24-bits and the most widely used character set as its capa-
ble of storing all characters globally.
How does a computer store text in memory?
It stores all types of data in bina-
ry, the way the memory can
differentiate each binary code is
by using a character set which
are agreed standards for refer-
ring to all the characters a com-
puter can use for example 65
How does the ALU perform arithmetic? stored in binary would represent
Using the binary addition rules, it converts denary values into bi-
nary integers and adds them respectively, same with subtraction •Mantissa: the number itself.
except the number we subtract is in twos complement form.
•Exponent: position of binary
Floating point numbers point.
A data type used to store an approximation of a real number in a •Both are stored in twos com-
way that can support a trade-off between range and precision. plement form.
•Used to store float numbers in binary.
Normalisation is the process of
•A fixed-point binary has the binary point in a fixed position moving the binary point so that
therefore range of numbers we can store is limited. the first digit after the point is a
•A floating-point binary can move the weight line including either significant digit. This maximises
a higher range of numbers or higher accuracy. precision in a given number of
bits.
Converting floating point to denary •Normalised positives start
1.Exponent tells us how much to move the binary point in the mantissa by. with 0 1.
2.We discard the exponent now and apply the normal weight line where •Normalised negatives start
the binary point is between ‘1’ and ‘1/2’ keeping the bits in the position with 1 0.
relative to the binary point before applying the weight line.
The benefits of buying summaries with Stuvia:
Guaranteed quality through customer reviews
Stuvia customers have reviewed more than 700,000 summaries. This how you know that you are buying the best documents.
Quick and easy check-out
You can quickly pay through credit card for the summaries. There is no membership needed.
Focus on what matters
Your fellow students write the study notes themselves, which is why the documents are always reliable and up-to-date. This ensures you quickly get to the core!
Frequently asked questions
What do I get when I buy this document?
You get a PDF, available immediately after your purchase. The purchased document is accessible anytime, anywhere and indefinitely through your profile.
Satisfaction guarantee: how does it work?
Our satisfaction guarantee ensures that you always find a study document that suits you well. You fill out a form, and our customer service team takes care of the rest.
Who am I buying these notes from?
Stuvia is a marketplace, so you are not buying this document from us, but from seller JackJordi05. Stuvia facilitates payment to the seller.
Will I be stuck with a subscription?
No, you only buy these notes for £3.49. You're not tied to anything after your purchase.