click below
click below
Normal Size Small Size show me how
data types
1.4 - data types
| Term | Definition |
|---|---|
| data types | how data is stored in memory |
| primitive data types | (almost universal) data types that can work as fundamental building blocks for that language |
| integer | any whole positive or negative number |
| real/float | any number |
| character | a single character from its character set |
| string | a collection of characters |
| Boolean | (normally true or false), on/off statements normally used for logic statements |
| casting | converting one data type to another |
| composite data types | "complex" data types which may be made from a sum of primitive data types |
| the real world | is analogues and continuous |
| the digital world | uses binary states |
| binary representation | arbitrary, yet "1" normally means the equivalent to "on" and "0" is normally equivalent to "off" |
| binary as a base | base 2, a base who's digits represent increasing powers of 2 |
| denary | base 10 (decimal), uses powers of 10 as digits |
| hexidecimal | base 16 (uses A-F for the "extra numbers" for 10-15 decimal), uses powers of 16 as digits |
| the digital world | represented by binary states |
| binary states representation | arbitrary, but generally “1” means the equivalent to “on” and “0” means the equivalent to “off” |
| binary as a base | base-2 |
| how to read base-2 | each digit represents an increasing power of 2, starting from 0 |
| binary to hexadecimal | convert each nibble into hexadecimal individually, then combine them in order |
| denary to hexadecimal | often easier to convert denary to binary, then into hexadecimal |
| conversions into denary | multiply each digit by the base to the power of the position (starting from 0), then sum everything together |
| representing negative numbers | sign/magnitude, 2's compliment |
| sign/magnitude | using the last bit as a +/- system (1 for negative) and having the positive part of the number be the same without the system |
| sign/magnitude downside | addition of binary digits becomes more complicated as the use of numbers to mean a state as well as well as a number makes them hard to use computationally (and it has a fewer range then two’s compliment) |
| two's compliment | Using the last bit as the negative version of itself and adding up terms to get a negative number can be done by writing the positive version of the number, copying it until the set bit and then inverting the number |
| two's compliment range | [-2^(n-1)] to [2^(n-1)-1] for n bits |
| sign/magnitude range | [-2^(n-1)-1] to [2^(n-1)-1] for n bits |
| binary addition rules | 1+1 = 0 carry 1 and 1+1+1 = 1 carry 1, 1+0 = 1 and 0+0 = 0 |
| binary subtraction | uses the same system as addition, but the negative number is written using two’s compliment |