Question 4 In the initialization code below, both function foo() and bar() return a random int type number. int x = foo(
Posted: Sat May 14, 2022 4:45 pm
Question 4
In the initialization code below, both
function foo() and bar() return a
random int type number.
int x = foo();
int y = bar();
unsigned ux = x;
unsigned uy = y;
Assume on a 32-bit architecture,
please justify whether the following claim is always true:
(Hints: x and y are
both signed integers. ux and uy are unsigned integers
cast from x and y.)
If x >= 0, then -x <= 0. Is this
true?
Select one:
True
False
Question 5
In the initialization code below, both
function foo() and bar() return a
random int type number.
int x = foo();
int y = bar();
unsigned ux = x;
unsigned uy = y;
Assume on a 32-bit architecture, please justify whether the
following claim is always true:
(Hints: x and y are
both signed integers. ux and uy are unsigned integers
cast from x and y.)
if x < 0, then we will always have (x * 2)
< 0. Is this true?
Select one:
True
False
Question 6
In the initialization code below, both
function foo() and bar() return a
random int type number.
int x = foo();
int y = bar();
unsigned ux = x;
unsigned uy = y;
Assume on a 32-bit architecture,
please justify whether the following claim is always true:
(Hints: x and y are
both signed integers. ux and uy are unsigned integers
cast from x and y.)
x & (x - 1) != 0. Is this true?
Select one:
True
False
In the initialization code below, both
function foo() and bar() return a
random int type number.
int x = foo();
int y = bar();
unsigned ux = x;
unsigned uy = y;
Assume on a 32-bit architecture,
please justify whether the following claim is always true:
(Hints: x and y are
both signed integers. ux and uy are unsigned integers
cast from x and y.)
If x >= 0, then -x <= 0. Is this
true?
Select one:
True
False
Question 5
In the initialization code below, both
function foo() and bar() return a
random int type number.
int x = foo();
int y = bar();
unsigned ux = x;
unsigned uy = y;
Assume on a 32-bit architecture, please justify whether the
following claim is always true:
(Hints: x and y are
both signed integers. ux and uy are unsigned integers
cast from x and y.)
if x < 0, then we will always have (x * 2)
< 0. Is this true?
Select one:
True
False
Question 6
In the initialization code below, both
function foo() and bar() return a
random int type number.
int x = foo();
int y = bar();
unsigned ux = x;
unsigned uy = y;
Assume on a 32-bit architecture,
please justify whether the following claim is always true:
(Hints: x and y are
both signed integers. ux and uy are unsigned integers
cast from x and y.)
x & (x - 1) != 0. Is this true?
Select one:
True
False