IPA FE Subject B 2026 Question 2
A question IPA Japan published in 令和8年度 基本情報技術者試験 科目B 公開問題 問2, translated into English. ITPEC is based on the same exams.
From the answer group below, select the correct answer to be inserted into blank in the program.
The function complement receives an 8-bit type value x as an argument, and returns the value that gives 00000000 when added to x. Addition of 8-bit type values is performed by regarding the values as unsigned binary numbers, and when an overflow occurs, the overflowed digit is ignored. The operators ∧, ∨, and ▽ represent bitwise logical product, logical sum, and exclusive logical sum, respectively.
Answer group
Explanation
x XOR 11111111, then add 1 — the 8-bit value that brings x to 00000000 is its two's complement: invert every bit, then add 1.
For the sum to wrap to 00000000, x + y must equal 28 = 256, so y = 28 − x = (255 − x) + 1. Subtracting x from 11111111 never borrows, it just flips every bit of x, and XOR with all ones does exactly that. The program already adds 00000001 on the next line, so the blank is x ▽ 11111111.
Check with x = 00000110 (6): inverting gives 11111001, adding 1 gives 11111010 (250), and 6 + 250 = 256 = 1 00000000; the overflowed digit is ignored, leaving 00000000.
Answer (f)
Why not others:
- •(a) —
x ∧ 01111111only clears the top bit; for 6 it returns 7, and 6 + 7 is not 0 - •(b) —
x ∧ 11111111leavesxunchanged, so the function returns x + 1 - •(c) and (d) — OR sets bits to 1 instead of inverting them; (d) gives
11111111for everyx, so the function always returns00000000 - •(e) —
x ▽ 01111111inverts only the low 7 bits, and x + y then always comes to10000000, never00000000
Key rule: The two's complement (the negative) of an n-bit value is "invert every bit, then add 1", and XOR with all ones is the bitwise inversion.
Math & Numbers · AI-written, may contain errors
This question comes from the past questions IPA Japan publishes, translated into English by ITPEC Practice. ITPEC Practice is an independent study tool and is not affiliated with IPA or ITPEC. See the original paper (PDF) or Report an issue.