Fill in chart by converting first colum from dec to bin and then following instr
ID: 3607708 • Letter: F
Question
Fill in chart by converting first colum from dec to bin and then following instructions
accelReading is just the first columb numbers converted to binary
raw sensor value (decimal)
(short int) accelReading (binary)
accelReading & (1<<11)
(boolean)
if(accelReading & (1<<11)) {
accelReading |= 0xF000; }
two's complement
(boolean)
signed value
(decimal)
0
0b0000 0000 0000 0000
FALSE
0b0000 0000 0000 0000
0
1
2
511
1024
2046
2047
2048
0b0000 1000 0000 0000
TRUE
0b1111 1000 0000 0000
0b0000 1000 0000 0000
-2048
2049
3072
3584
-
4094
4095
raw sensor value (decimal)
(short int) accelReading (binary)
accelReading & (1<<11)
(boolean)
if(accelReading & (1<<11)) {
accelReading |= 0xF000; }
two's complement
(boolean)
signed value
(decimal)
0
0b0000 0000 0000 0000
FALSE
0b0000 0000 0000 0000
0
1
2
511
1024
2046
2047
2048
0b0000 1000 0000 0000
TRUE
0b1111 1000 0000 0000
0b0000 1000 0000 0000
-2048
2049
3072
3584
-
4094
4095
Explanation / Answer
raw sensor value (decimal)
(short int) accelReading (binary)
accelReading & (1<<11)
(boolean)
if(accelReading & (1<<11)) {
accelReading |= 0xF000; }
two's complement
(boolean)
signed value
(decimal)
0
0b0000 0000 0000 0000
FALSE
0b0000 0000 0000 0000
0
raw sensor value (decimal)
(short int) accelReading (binary)
accelReading & (1<<11)
(boolean)
if(accelReading & (1<<11)) {
accelReading |= 0xF000; }
two's complement
(boolean)
signed value
(decimal)
0
0b0000 0000 0000 0000
FALSE
0b0000 0000 0000 0000
0
1 0b0000 0000 0000 0001 FALSE 0b0000 0000 0000 0000 1 2 0b0000 0000 0000 0010 FALSE 0b0000 0000 0000 0000 2 511 0b0000 0001 1111 1111 FALSE 0b0000 0000 0000 0000 511 1024 0b0000 0100 0000 0000 FALSE 0b0000 0000 0000 0000 1024 2046 0b0000 0111 1111 1110 FALSE 0b0000 0000 0000 0000 2046 2047 0b0000 0111 1111 1111 FALSE 0b0000 0000 0000 0000 2047 2048 0b0000 1000 0000 0000 TRUE 0b1111 1000 0000 0000 0b0000 1000 0000 0000 -2048 2049 0b0000 1000 0000 0001 TRUE 0b1111 1000 0000 0001 0b0000 0111 1111 1111 -2049 3072 0b0000 1100 0000 0000 TRUE 0b1111 1100 0000 0000 0b0000 0100 0000 0000 -3072 3584 0b0000 1110 0000 0000 TRUE 0b1111 1110 0000 0000 0b0000 0010 0000 0000 -3584 4094 0b0000 1111 1111 1110 TRUE 0b1111 1111 1111 1110 0b0000 0000 0000 0010 -4094 4095 0b0000 1111 1111 1111 TRUE 0b1111 1111 1111 1111 0b0000 0000 0000 0001 -4095Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.