Integer Representation & Overflow MCQs

13 MCQs  — Data Types MCQs  (Page 1 of 2)

Practice Integer Representation & Overflow MCQs with correct answers and explanations. These questions are from the Data Types MCQs section.

In C++, what happens when a signed int overflows (for example, INT_MAX + 1)?
A std::overflow_error is thrown
Undefined behavior
It saturates at INT_MAX
It wraps to INT_MIN as guaranteed by the standard
In Python 3, what is the result of 2 ** 100?
It wraps around to a negative number
The exact integer 1267650600228229401496703205376
OverflowError
A float in scientific notation
What is the result of adding 01111111 + 00000001 as 8-bit two's complement integers?
11111111, which represents -1
10000000, which represents 128
10000000, which represents -128 (signed overflow)
00000000 with a carry
Which representation has two representations of zero (+0 and -0)?
Excess-128 only
Unsigned binary
Sign-magnitude (and one's complement)
Two's complement