Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

please help me: Data Representations Topics covered: Base conversions, Binary, H

ID: 3884145 • Letter: P

Question

please help me:

Data Representations

Topics covered: Base conversions, Binary, Hexadecimal, Binary Addition/multiplication, 2’s Complement, Extended Precision, Floating Point encodings

Task List (2):

Task 1:   Answer the question.

What is the hex code for an integer which contains alternating 1’s and 0’s, starting with a 1?

What is the hex code for an integer where the most significant byte is all 1’s, the next is all 1’s, and next is all 0’s, and the last is all 1’s?

What is the hex code for the most positive int value in C/C++?

What is the hex code for the most negative int value in C/C++?

What is the 2’s complement representation of 70 using 8 bits?

What is the 2’s complement representation of -34 using 8 bits?

Add 28 and -9 using 2’s complement using 8 bits.

Add -52 and -4 using 2’s complement using 8 bits.

Perform 55 - 89 using 2’s complement using 8 bits.

If you had the C code int a = 68, what shifting operation could be done to multiply a by 64 without using multiplication?

If you had the C code int a = 68, and you did a = a>>1 fifty times, what would be the value of a? Explain why.

If you had the C code int a = 68, and you did a = a<<1 fifty times, what would be the value of a? Explain why.

If you had the C code int a = -68, and you did a = a>>1 thirty three times, what would be the value of a? Explain why.

Explanation / Answer

If you had the C code int a = 68, and you did a = a>>1 fifty times, what would be the value of a?

value of a=0

The Right shift operator performs num/2 operation like below.

Value of a =68
Binary Value = 01000100
The shift operator works on binary value of a
After 1 shift
Value of a =34
Binary Value = 00100010
After 2 shift
Value of a =17
Binary Value = 00010001
After 3 shift
Value of a =8
Binary Value = 00001000
After 4 shift
Value of a =4
Binary Value = 00000100
After 5 shift
Value of a =2
Binary Value = 00000010
After 6 shift
Value of a =1
Binary Value = 00000001
After 7 shift
Value of a =0
Binary Value = 00000000
After 8 shift
Value of a =0
Binary Value = 00000000
After 9 shift
Value of a =0
Binary Value = 00000000
After 10 shift
Value of a =0
Binary Value = 00000000
After 11 shift
Value of a =0
Binary Value = 00000000
After 12 shift
Value of a =0
Binary Value = 00000000
After 13 shift
Value of a =0
Binary Value = 00000000
After 14 shift
Value of a =0
Binary Value = 00000000
After 15 shift
Value of a =0
Binary Value = 00000000
After 16 shift
Value of a =0
Binary Value = 00000000
After 17 shift
Value of a =0
Binary Value = 00000000
After 18 shift
Value of a =0
Binary Value = 00000000
After 19 shift
Value of a =0
Binary Value = 00000000
After 20 shift
Value of a =0
Binary Value = 00000000
After 21 shift
Value of a =0
Binary Value = 00000000
After 22 shift
Value of a =0
Binary Value = 00000000
After 23 shift
Value of a =0
Binary Value = 00000000
After 24 shift
Value of a =0
Binary Value = 00000000
After 25 shift
Value of a =0
Binary Value = 00000000
After 26 shift
Value of a =0
Binary Value = 00000000
After 27 shift
Value of a =0
Binary Value = 00000000
After 28 shift
Value of a =0
Binary Value = 00000000
After 29 shift
Value of a =0
Binary Value = 00000000
After 30 shift
Value of a =0
Binary Value = 00000000
After 31 shift
Value of a =0
Binary Value = 00000000
After 32 shift
Value of a =0
Binary Value = 00000000
After 33 shift
Value of a =0
Binary Value = 00000000
After 34 shift
Value of a =0
Binary Value = 00000000
After 35 shift
Value of a =0
Binary Value = 00000000
After 36 shift
Value of a =0
Binary Value = 00000000
After 37 shift
Value of a =0
Binary Value = 00000000
After 38 shift
Value of a =0
Binary Value = 00000000
After 39 shift
Value of a =0
Binary Value = 00000000
After 40 shift
Value of a =0
Binary Value = 00000000
After 41 shift
Value of a =0
Binary Value = 00000000
After 42 shift
Value of a =0
Binary Value = 00000000
After 43 shift
Value of a =0
Binary Value = 00000000
After 44 shift
Value of a =0
Binary Value = 00000000
After 45 shift
Value of a =0
Binary Value = 00000000
After 46 shift
Value of a =0
Binary Value = 00000000
After 47 shift
Value of a =0
Binary Value = 00000000
After 48 shift
Value of a =0
Binary Value = 00000000
After 49 shift
Value of a =0
Binary Value = 00000000
After 50 shift
Value of a =0
Binary Value = 00000000

After 6th shift the value become 0 because 0/2=0 for remaining all shifts.

If you had the C code int a = -68, and you did a = a>>1 thirty three times, what would be the value

The value of a=76561193665298432 because

The left shift operator performs num*2 like this.

Value of a =68
Binary Value = 1000100
The shift operator works on binary value of a
After 1 shift
Value of a =136
Binary Value = 10001000
After 2 shift
Value of a =272
Binary Value = 100010000
After 3 shift
Value of a =544
Binary Value = 1000100000
After 4 shift
Value of a =1088
Binary Value = 10001000000
After 5 shift
Value of a =2176
Binary Value = 100010000000
After 6 shift
Value of a =4352
Binary Value = 1000100000000
After 7 shift
Value of a =8704
Binary Value = 10001000000000
After 8 shift
Value of a =17408
Binary Value = 100010000000000
After 9 shift
Value of a =34816
Binary Value = 1000100000000000
After 10 shift
Value of a =69632
Binary Value = 10001000000000000
After 11 shift
Value of a =139264
Binary Value = 100010000000000000
After 12 shift
Value of a =278528
Binary Value = 1000100000000000000
After 13 shift
Value of a =557056
Binary Value = 10001000000000000000
After 14 shift
Value of a =1114112
Binary Value = 100010000000000000000
After 15 shift
Value of a =2228224
Binary Value = 1000100000000000000000
After 16 shift
Value of a =4456448
Binary Value = 10001000000000000000000
After 17 shift
Value of a =8912896
Binary Value = 100010000000000000000000
After 18 shift
Value of a =17825792
Binary Value = 1000100000000000000000000
After 19 shift
Value of a =35651584
Binary Value = 10001000000000000000000000
After 20 shift
Value of a =71303168
Binary Value = 100010000000000000000000000
After 21 shift
Value of a =142606336
Binary Value = 1000100000000000000000000000
After 22 shift
Value of a =285212672
Binary Value = 10001000000000000000000000000
After 23 shift
Value of a =570425344
Binary Value = 100010000000000000000000000000
After 24 shift
Value of a =1140850688
Binary Value = 1000100000000000000000000000000
After 25 shift
Value of a =2281701376
Binary Value = 10001000000000000000000000000000
After 26 shift
Value of a =4563402752
Binary Value = 100010000000000000000000000000000
After 27 shift
Value of a =9126805504
Binary Value = 1000100000000000000000000000000000
After 28 shift
Value of a =18253611008
Binary Value = 10001000000000000000000000000000000
After 29 shift
Value of a =36507222016
Binary Value = 100010000000000000000000000000000000
After 30 shift
Value of a =73014444032
Binary Value = 1000100000000000000000000000000000000
After 31 shift
Value of a =146028888064
Binary Value = 10001000000000000000000000000000000000
After 32 shift
Value of a =292057776128
Binary Value = 100010000000000000000000000000000000000
After 33 shift
Value of a =584115552256
Binary Value = 1000100000000000000000000000000000000000
After 34 shift
Value of a =1168231104512
Binary Value = 10001000000000000000000000000000000000000
After 35 shift
Value of a =2336462209024
Binary Value = 100010000000000000000000000000000000000000
After 36 shift
Value of a =4672924418048
Binary Value = 1000100000000000000000000000000000000000000
After 37 shift
Value of a =9345848836096
Binary Value = 10001000000000000000000000000000000000000000
After 38 shift
Value of a =18691697672192
Binary Value = 100010000000000000000000000000000000000000000
After 39 shift
Value of a =37383395344384
Binary Value = 1000100000000000000000000000000000000000000000
After 40 shift
Value of a =74766790688768
Binary Value = 10001000000000000000000000000000000000000000000
After 41 shift
Value of a =149533581377536
Binary Value = 100010000000000000000000000000000000000000000000
After 42 shift
Value of a =299067162755072
Binary Value = 1000100000000000000000000000000000000000000000000
After 43 shift
Value of a =598134325510144
Binary Value = 10001000000000000000000000000000000000000000000000
After 44 shift
Value of a =1196268651020288
Binary Value = 100010000000000000000000000000000000000000000000000
After 45 shift
Value of a =2392537302040576
Binary Value = 1000100000000000000000000000000000000000000000000000
After 46 shift
Value of a =4785074604081152
Binary Value = 10001000000000000000000000000000000000000000000000000
After 47 shift
Value of a =9570149208162304
Binary Value = 100010000000000000000000000000000000000000000000000000
After 48 shift
Value of a =19140298416324608
Binary Value = 1000100000000000000000000000000000000000000000000000000
After 49 shift
Value of a =38280596832649216
Binary Value = 10001000000000000000000000000000000000000000000000000000
After 50 shift
Value of a =76561193665298432
Binary Value = 100010000000000000000000000000000000000000000000000000000

Note:- a should be long for this because 76561193665298432 value is not in a range of int in c language.

If you had the C code int a = -68, and you did a = a>>1 thirty three times, what would be the value

The value of a=-584115552256 because

The left shift operator performs num*2 like this.

Value of a =-68
Binary Value = 1111111111111111111111111111111111111111111111111111111110111100
The shift operator works on binary value of a
After 1 shift
Value of a =-136
Binary Value = 1111111111111111111111111111111111111111111111111111111101111000
After 2 shift
Value of a =-272
Binary Value = 1111111111111111111111111111111111111111111111111111111011110000
After 3 shift
Value of a =-544
Binary Value = 1111111111111111111111111111111111111111111111111111110111100000
After 4 shift
Value of a =-1088
Binary Value = 1111111111111111111111111111111111111111111111111111101111000000
After 5 shift
Value of a =-2176
Binary Value = 1111111111111111111111111111111111111111111111111111011110000000
After 6 shift
Value of a =-4352
Binary Value = 1111111111111111111111111111111111111111111111111110111100000000
After 7 shift
Value of a =-8704
Binary Value = 1111111111111111111111111111111111111111111111111101111000000000
After 8 shift
Value of a =-17408
Binary Value = 1111111111111111111111111111111111111111111111111011110000000000
After 9 shift
Value of a =-34816
Binary Value = 1111111111111111111111111111111111111111111111110111100000000000
After 10 shift
Value of a =-69632
Binary Value = 1111111111111111111111111111111111111111111111101111000000000000
After 11 shift
Value of a =-139264
Binary Value = 1111111111111111111111111111111111111111111111011110000000000000
After 12 shift
Value of a =-278528
Binary Value = 1111111111111111111111111111111111111111111110111100000000000000
After 13 shift
Value of a =-557056
Binary Value = 1111111111111111111111111111111111111111111101111000000000000000
After 14 shift
Value of a =-1114112
Binary Value = 1111111111111111111111111111111111111111111011110000000000000000
After 15 shift
Value of a =-2228224
Binary Value = 1111111111111111111111111111111111111111110111100000000000000000
After 16 shift
Value of a =-4456448
Binary Value = 1111111111111111111111111111111111111111101111000000000000000000
After 17 shift
Value of a =-8912896
Binary Value = 1111111111111111111111111111111111111111011110000000000000000000
After 18 shift
Value of a =-17825792
Binary Value = 1111111111111111111111111111111111111110111100000000000000000000
After 19 shift
Value of a =-35651584
Binary Value = 1111111111111111111111111111111111111101111000000000000000000000
After 20 shift
Value of a =-71303168
Binary Value = 1111111111111111111111111111111111111011110000000000000000000000
After 21 shift
Value of a =-142606336
Binary Value = 1111111111111111111111111111111111110111100000000000000000000000
After 22 shift
Value of a =-285212672
Binary Value = 1111111111111111111111111111111111101111000000000000000000000000
After 23 shift
Value of a =-570425344
Binary Value = 1111111111111111111111111111111111011110000000000000000000000000
After 24 shift
Value of a =-1140850688
Binary Value = 1111111111111111111111111111111110111100000000000000000000000000
After 25 shift
Value of a =-2281701376
Binary Value = 1111111111111111111111111111111101111000000000000000000000000000
After 26 shift
Value of a =-4563402752
Binary Value = 1111111111111111111111111111111011110000000000000000000000000000
After 27 shift
Value of a =-9126805504
Binary Value = 1111111111111111111111111111110111100000000000000000000000000000
After 28 shift
Value of a =-18253611008
Binary Value = 1111111111111111111111111111101111000000000000000000000000000000
After 29 shift
Value of a =-36507222016
Binary Value = 1111111111111111111111111111011110000000000000000000000000000000
After 30 shift
Value of a =-73014444032
Binary Value = 1111111111111111111111111110111100000000000000000000000000000000
After 31 shift
Value of a =-146028888064
Binary Value = 1111111111111111111111111101111000000000000000000000000000000000
After 32 shift
Value of a =-292057776128
Binary Value = 1111111111111111111111111011110000000000000000000000000000000000
After 33 shift
Value of a =-584115552256
Binary Value = 1111111111111111111111110111100000000000000000000000000000000000

Note:- a should be long for this because -584115552256value is not in a range of int in c language.