100 likes | 248 Views
Type of Information. Why variables matter… Any information has a “Data Type”. Why do data-types matter?. Size and Weight Data-types are means of controlling how much memory is used per “unit", and Specifying/defining what kind of operations apply to a variable. Basic Data Understanding.
E N D
Type of Information Why variables matter… Any information has a “Data Type”
Why do data-types matter? • Size and Weight • Data-types are means of • controlling how much memory is used per “unit", and • Specifying/defining what kind of operations apply to a variable
Basic Data Understanding • How exactly is the data stored in the memory? • binary (i.e. machine) language: 0 and 1’s • How is the number 2 represented then? • Remember that the symbol we see is NOT the value represented by it. • For example: what number do these represent? V ||||
Definitions • Reference: • a single 0 or 1 is called a bit = “binary digit” • a group of 8 is called a byte. • Most data is expressed in bytes. 0010111000110111100110000001011111010110001101101010000101000100010101010001110111110100100110011001000011011101111110000100001011100001010111100011000100000100000110010011111101100101100101110001110100101111011100011100010010100100001010110000001010101100110101101111100011101001101000110111111100000001100100001011011010100101010000100000111100011111001011100111001001010101101000000000101101000010000011111111011110100111100101111101010001101011100000110000001110011110100010011110111011010100000110011000010111001110011010110001111111111011101011111110100010111100111010000010110111101100011100001011101010001001010101111011100001101011010111111000001100111110100110010100000111011100110010100111
Definition – a DATA TYPE • Simply put: "The type-of-data stored in a variable" 2 bytes 8 bytes
Example Remember: “A double is 8 bytes” • How many 0’s and 1’s did this last code use to store the values?
Importance of planning ahead • Apollo Guidance Computer • 4 kB of magnetic core with r/w memory • 16-bit memory buffer register, to hold data words moving to and from memory • Shuttle • 5 identical redundant IBM 32-bit general purpose computers (GPCs), model AP-101 • The IBM AP-101 computers originally had about 424 kilobytes of magnetic core memory each.
Lessons learned • Data types are a way of controlling memory usage and operations that can be performed • MATLAB defaults to either double or char • A double takes 8 bytes (64 bits in memory) • A char takes 2 bytes (16 bits in memory) per letter Interesting fact: Most languages require the PROGRAMMER to decide ahead of time what each variable will be! Size of documents are usually referred to in Kilo/Mega/Giga Bytes! Now you know what it means!
Vocabulary • New Vocabulary: • a bit • a byte • numerical vs. text • double • char