This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
notes:cprog:spring2024:projects:dtr0 [2024/01/27 15:02] – created wedge | notes:cprog:spring2024:projects:dtr0 [2024/02/14 20:39] (current) – [INTEGER VALUES] cgrant9 | ||
---|---|---|---|
Line 10: | Line 10: | ||
====INTEGER VALUES==== | ====INTEGER VALUES==== | ||
+ | An integer is a number that has no fractional component, so 2, 6, -15, and 17356 are all considered integers, while 13½, -1/12, π, and 5.2 are not. | ||
+ | For our use, we split integers into 2 categories, signed and unsigned. A signed integer is any whole number, negative or positive, while an unsigned integer is a strictly positive whole number (and zero). | ||
+ | |||
+ | In this project we are looking at 10 different types of data values, that are all variations of integers with different byte sizes: | ||
+ | < | ||
+ | unsigned long long int --- 8 bytes | ||
+ | signed long int --- 8 bytes | ||
+ | unsigned long int --- 8 bytes | ||
+ | signed int --- 4 bytes | ||
+ | unsigned int --- 4 bytes | ||
+ | signed half int --- 2 bytes | ||
+ | unsigned half int --- 2 bytes | ||
+ | signed char --- 1 byte | ||
+ | unsigned char --- 1 byte</ | ||
+ | |||
+ | |||
+ | |||
+ | |||
====REPRESENTATION: | ====REPRESENTATION: | ||
+ | Each of the data value types has an associated size, ranging from 1 byte (8 bits) to 32 byte (256 bits), so the length of the number in binary will be given based on the type. | ||
+ | For example: | ||
+ | < | ||
+ | 4 bytes | ||
+ | 0000000000000000000000000000000 | ||
+ | unsigned half int: | ||
+ | 2 bytes | ||
+ | 0000000000000000</ | ||
+ | Whether or not the data type is signed changes how the first bit of the number interacts with the rest, in a signed number the first bit acts as a positive or negative sign | ||
+ | For example: | ||
+ | < | ||
+ | 1 Byte | ||
+ | Binary: 10000000 | ||
+ | Decimal: -128 | ||
+ | Binary: 00000000 | ||
+ | Decimal: 0 | ||
+ | </ | ||
+ | For further information on how negative act in binary try looking here: | ||
+ | |||
+ | https:// | ||
+ | |||
+ | Each place value in binary is worth double the previous | ||
+ | < | ||
+ | Is worth 8 4 2 1</ | ||
+ | To convert a binary number to decimal, just add each place value | ||
+ | Ex: | ||
+ | < | ||
+ | (1*128)+(1*64)+(0*32)+(1*16)+(0*8)+(0*4)+(1*2)+(0*1) | ||
+ | =210</ | ||
====REPRESENTATION: | ====REPRESENTATION: | ||
+ | |||
+ | Hexadecimal Table: | ||
+ | |||
+ | '' | ||
+ | < | ||
+ | Hex | ||
+ | 0 0000 0 | ||
+ | 1 0001 1 | ||
+ | 2 0010 2 | ||
+ | 3 0011 3 | ||
+ | 4 0100 4 | ||
+ | 5 0101 5 | ||
+ | 6 0110 6 | ||
+ | 7 0111 7 | ||
+ | 8 1000 8 | ||
+ | 9 1001 9 | ||
+ | A 1010 10 | ||
+ | B 1011 11 | ||
+ | C 1100 12 | ||
+ | D 1101 13 | ||
+ | E 1110 14 | ||
+ | F 1111 15 | ||
+ | ----------------------- | ||
+ | 10 | ||
+ | 20 | ||
+ | 30 | ||
+ | 40 | ||
+ | 50 | ||
+ | 60 | ||
+ | 70 | ||
+ | 80 | ||
+ | 90 | ||
+ | A0 | ||
+ | B0 | ||
+ | C0 | ||
+ | D0 | ||
+ | E0 | ||
+ | F0 | ||
+ | ------------------------- | ||
+ | 11 | ||
+ | 12 | ||
+ | 13 | ||
+ | 14 | ||
+ | 15 | ||
+ | 16 | ||
+ | 17 | ||
+ | 18 | ||
+ | ------------------------- | ||
+ | FF | ||
+ | 100 | ||
+ | </ | ||
+ | |||
+ | -//Single digit// | ||
+ | < | ||
+ | 5 + A = | ||
+ | (5) + (10) | ||
+ | Decimal = 15 | ||
+ | Hexadecimal = F | ||
+ | | ||
+ | MAX SINGLE = F or 15 or 1111 | ||
+ | </ | ||
+ | |||
+ | -//Double Digit//- | ||
+ | < | ||
+ | 1F + AB | ||
+ | ((16*1)+15) + ((16*10)+11) | ||
+ | Decimal = 31 + 171 = 202 | ||
+ | Hexadecimal = CA | ||
+ | | ||
+ | MAX DOUBLE DIGIT = FF or 255 or 11111111 | ||
+ | </ | ||
====STORAGE: | ====STORAGE: | ||
====BITWISE LOGIC: AND==== | ====BITWISE LOGIC: AND==== | ||
+ | |||
+ | __An AND logic gate has 2 inputs/ | ||
+ | |||
+ | **EXAMPLE** - To login you need both a valid email and password; | ||
+ | < | ||
+ | (Valid email)------- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | (Invalid password)-- | ||
+ | |||
+ | Binary view of previous; | ||
+ | ( 1 ) -------------- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | ( 0 ) -------------- | ||
+ | </ | ||
+ | |||
+ | |||
+ | -AND gate turned on- | ||
+ | < | ||
+ | ( 1 ) -------------- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | ( 1 ) -------------- | ||
+ | </ | ||
+ | |||
+ | //List of all AND gate Interactions// | ||
+ | - 0 & 0 = 0 | ||
+ | - 0 & 1 = 0 | ||
+ | - 1 & 1 = 1 | ||
+ | - 1 & 0 = 0 | ||
+ | |||
====BITWISE LOGIC: OR==== | ====BITWISE LOGIC: OR==== | ||
+ | __An OR logic gate has 2 input/ | ||
+ | |||
+ | EXAMPLE - You can have a free ice cream cone | ||
+ | < | ||
+ | (1scoopOfVanilla)--- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | (0scoopsOfChocolate) | ||
+ | |||
+ | (1scoopOfVanilla)--- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | (1scoopsOfChocolate) | ||
+ | |||
+ | (0scoopOfVanilla)--- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | (0scoopsOfChocolate) | ||
+ | |||
+ | |||
+ | </ | ||
+ | |||
+ | //List of all OR gate Interactions// | ||
+ | - 0 & 0 = 0 | ||
+ | - 0 & 1 = 1 | ||
+ | - **1 & 1 = 1** | ||
+ | - 1 & 0 = 1 | ||
====BITWISE LOGIC: XOR==== | ====BITWISE LOGIC: XOR==== | ||
+ | __An XOR logic gate has 2 input/ | ||
+ | |||
+ | EXAMPLE - You can have a free ice cream cone, but you can only have one scoop of vanilla or chocolate | ||
+ | < | ||
+ | (1scoopOfVanilla)--- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | (0scoopsOfChocolate) | ||
+ | |||
+ | (0scoopOfVanilla)--- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | (1scoopsOfChocolate) | ||
+ | |||
+ | (0scoopOfVanilla)--- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | (0scoopsOfChocolate) | ||
+ | |||
+ | (1scoopOfVanilla)--- | ||
+ | | | ||
+ | | ||
+ | | | ||
+ | (1scoopsOfChocolate) | ||
+ | |||
+ | </ | ||
+ | |||
+ | //List of all XOR gate Interactions// | ||
+ | - 0 & 0 = 0 | ||
+ | - 0 & 1 = 1 | ||
+ | - **1 & 1 = 0** | ||
+ | - 1 & 0 = 1 | ||
====BITWISE LOGIC: NOT==== | ====BITWISE LOGIC: NOT==== | ||
+ | A NOT gate inverts the input. It only has a single input. | ||
+ | |||
+ | EXAMPLE - Its opposite day | ||
+ | < | ||
+ | |||
+ | ( YES )------|[NOT]> | ||
+ | |||
+ | ( 1 )--------|[NOT]> | ||
+ | |||
+ | </ | ||
+ | |||
+ | //List of possible NOT gate interactions// | ||
+ | - 1 = 0 | ||
+ | - 0 = 1 |