Unit 6 Data Types Flashcards
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
Real
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.
Character
A character is a single symbol used by a computer. These include the letters A to Z, the numbers 0to 9and hundreds of symbols like %, £
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 storingtextandphonenumberswhichstartwitha0,whichnumericdatatypeslike integers would cut off.
Boolean
Named after the mathematician George Boole (hence written with a capital B), values taken by a Boolean data type are restricted to Trueand False. Booleans are useful for recording data that can only take two values, like the state of a power button or whether a line of code has been executed.
Binary to Decimal
The least significant bit of a binary number is the one furthest to the right, while the most significant bit is furthest to the left. When representing positive integers, the least significant bit always represents a value of 1, with the 2nd least significant bit representing a value of 2, then 4, 8, etc.
Decimal to Binary
If you have a decimal (denary) number to convert into binary, the first step is to find the largest power of two which is smaller than the number you’re converting. Then write out place values in powers of two up to this power.