東京大学 情報理工学系研究科 創造情報学専攻 2026年2月実施 筆記試験 第1問
Author
Description
Memorized version (English)
Consider an 8-bit binary number (e.g., 0b10110111, where underscores _ can be freely added as separators without affecting the meaning).
- [7:4] (Bits 7, 6, 5, 4): represent the exponent E.
- [3:0] (Bits 3, 2, 1, 0): represent the mantissa M.
The floating-point value represented by this binary number is calculated using the formula: This is called EM notation.
Answer the following questions.
(1) How is 1.0 represented in EM notation?
(2) What is the decimal value of the binary number 0b1000_1000?
(3) What are the decimal values of the largest and the second largest numbers that can be represented?
We define functions as follows:
- : Input a decimal number ; output the largest decimal number strictly less than that can be exactly represented in EM notation.
- : Input a binary EM representation ; output the corresponding decimal value.
- : Input a decimal number ; output the EM representation (binary) of the largest number strictly less than that can be exactly represented in EM notation.
(4) Prove: For two binary numbers and , if , then .
(5) Prove: Among all numbers representable in EM notation, no two numbers have the same EM representation (i.e., the mapping is unique).
(6) Calculate the value of .
(7) Calculate the value of .
(8) Let and be numbers that can be exactly represented in EM notation, with . Let be the integer part of the decimal value of . Find a value for (provide the decimal value) such that the lower 4 bits (the Mantissa part, ) of correspond to the value for every .
题目描述
考虑 8 位二进制数(如 0b10110111,可任意加入下划线作分隔,不影响数值):高 4 位 [7:4] 表示指数 ,低 4 位 [3:0] 表示尾数 。其浮点值定义为
称为 EM 表示。
- 数值 1.0 的 EM 二进制表示是什么?
0b1000_1000的十进制值是多少?- 可表示的最大数与第二大数分别是多少?
定义:
- :对十进制数 ,返回严格小于 的、可被 EM 精确表示的最大十进制数;
- :把 EM 二进制表示 转成对应十进制值;
- :对十进制数 ,返回严格小于 的最大可精确表示数之 EM 二进制表示。
-
证明对两个 8 位二进制编码 ,有 。
-
证明 EM 表示具有唯一性,即不会有两个数对应同一个 EM 表示。
-
计算 。
-
计算
-
均可由 EM 精确表示,且 。令 为 十进制值的整数部分。求一个 (给十进制值),使对每个这样的 , 的低 4 位尾数字段
[3:0]所表示的值都等于 。
Kai
(1)
Taking and gives . Therefore the representation is 0b0111_0000.
(2)
Here and , so the value is
(3)
The largest exponent is . Taking mantissas and gives, respectively,
Their representations are 0b1111_1111 and 0b1111_1110.
(4)
Write an unsigned encoding as . At fixed , increasing by one increases the value by . Across an exponent boundary,
Thus every adjacent pair of encodings has strictly increasing values. Applying this repeatedly proves .
(5)
Each encoding determines exactly one pair and hence one value. Conversely, (4) proves that distinct encodings give distinct values. Therefore every representable value has exactly one encoding.
(6)
Near , the spacing is . Since
we obtain . The requested ordinary sum is
(7)
Their sum is , which lies strictly between and the next representable value . Hence the answer is .
(8)
Under the stated strictly less than definition of , no representable satisfies the condition.
There are only 256 candidates. Exact evaluation for and leaves just . But for the representable value , we have
so encodes , with mantissa , whereas . This eliminates the last candidate.
The following finite check uses exact rational arithmetic and includes every encoding. The predecessor of an exactly representable input is selected with bisect_left, as required by the strict inequality.
from fractions import Fraction
from bisect import bisect_left
values = [Fraction(16 + (code & 15), 16) * Fraction(2) ** ((code >> 4) - 7)
for code in range(256)]
def mantissa_below(z):
code = bisect_left(values, z) - 1
if code < 0:
raise ValueError("No representable value is strictly below z")
return code & 15
candidates = [h for h in values
if all(mantissa_below(e + h) == int(e)
for e in [Fraction(1), Fraction(2)])]
assert candidates == [Fraction(17)]
assert mantissa_below(Fraction(17) + Fraction(1, 128)) == 1
assert [h for h in values
if all(mantissa_below(e + h) == int(e)
for e in values if e <= 15)] == []