Questions: Integer and Floating-Point Number Types

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

Why does `0.1 + 0.2` produce approximately `0.30000000000000004` rather than exactly `0.3` in most programming languages?

AThis is a bug in the language's math library that has not been patched
BFloating-point arithmetic is inherently random and produces slightly different results each time
CThe number 0.1 cannot be represented exactly in binary, just as 1/3 cannot be written exactly in decimal — so a rounding error is introduced during representation, not calculation
DThe CPU performs addition before converting binary to decimal, introducing a translation error
Question 2 Multiple Choice

A program converts a very large 64-bit integer (e.g., 2^60) to a 64-bit float before doing arithmetic. What risk does this introduce?

AThe program will throw a runtime error because floats cannot store values that large
BThe value will always be rounded down to the nearest power of 2
CThe integer's value may be silently rounded because a 64-bit float only stores about 15–16 significant decimal digits, which may be fewer than the integer requires
DNo risk — converting integers to floats is always lossless regardless of magnitude
Question 3 True / False

In Python specifically, integer arithmetic is exact with no overflow risk, regardless of how large the numbers get.

TTrue
FFalse
Question 4 True / False

Floating-point imprecision is unpredictable — you can't know in advance which calculations will produce rounding errors.

TTrue
FFalse
Question 5 Short Answer

Why is it a mistake to compare floating-point numbers with ==, and what should you do instead?

Think about your answer, then reveal below.