1.4.1 - Data Types Flashcards
Why is it important to make sure data is stored with the right type?
So the right operations can be performed on it.
What is an integer?
An integer is a whole number. Integers include zero and negative numbers, they just can’t have a fractional part. Integers are useful for counting things.
What is a real number?
Real numbers are positive or negative numbers which can, but do not necessarily, have a fractional part. Reals are useful for measuring things. All integers are real numbers. Real numbers can also be represented using floating point, which is explained later.
What is a character?
A character is a single symbol used by a computer. These include the letters A to Z, the numbers 0 to 9 and hundreds of symbols like %, £ and :)
What is a string?
A string is a collection of characters. While a string can be used to store a single character, they can also be used to store many characters in succession.
Strings are useful for storing text and phone numbers which start with a 0, which numeric data types like integers would cut off.
What is a Boolean?
Named after the mathematician George Boole (hence written with a capital B), values taken by a Boolean data type are restricted to True and False. Booleans are useful for recording data that can only take two values.
What does base 2 mean?
Each step in place represents a value of two times the previous place.
What is a single binary digit?
A single binary digit is called a bit, and eight binary digits can be combined to form a byte.
Entertainingly, half a byte (four bits) is called a nybble.
What is the least significant bit of a binary number?
The one furthest to the right.
What is sign magnitude?
The most basic way to represent negative numbers in binary. The equivalent of adding a + or - sign, with a leading 1 for a negative and leading 0 for a positive.
What is two’s complement?
A method of representing negative numbers in binary which makes the most significant bit negative.
How to convert to two’s complement.
Flip all of the bits in the positive version of a binary number and add one.
Why is two’s complement good?
It makes subtraction in binary easy. You simply add the twos complement version of a number.
How to convert from hexadecimal to binary?
Convert each hex digit to a decimal, then binary nybble. Then, combine the nybbles.
How to work out floating point binary.
Mantissa starts with decimal point after most significant bit. Moves places to the right, depending on what the exponent is in decimal.