Question:medium

Consider the syntax-directed translation with non-terminals N, I, F, B and the rules:

\[ \begin{aligned} N &\to I\ \#\ F \qquad && N.val = I.val + F.val \\ I &\to I_1\ B \qquad && I.val = 2 \times I_1.val + B.val \\ I &\to B \qquad && I.val = B.val \\ F &\to B\ F_1 \qquad && F.val = \tfrac12 \big(B.val + F_1.val\big) \\ F &\to B \qquad && F.val = \tfrac12 B.val \\ B &\to 0 \qquad && B.val = 0 \\ B &\to 1 \qquad && B.val = 1 \end{aligned} \] Find the value computed for the input string 10#011 (rounded to three decimals).

Show Hint

The integer rule $I \to I B$ with $I.val=2\,I_1.val+B.val$ accumulates binary digits left-to-right. The fractional rule $F \to B F$ with $F.val=\tfrac12(B.val+F_1.val)$ yields $\sum b_i/2^i$ for bits after ``\#''.
Updated On: Feb 3, 2026
Show Solution

Solution and Explanation

Step 1: Interpret the binary number structure

The given binary number is:
10.011

It consists of:
• Integer part: 10
• Fractional part: 011


Step 2: Convert the integer part to decimal

Binary 10 represents:

1 × 21 + 0 × 20 = 2

So, integer value = 2


Step 3: Convert the fractional part to decimal

Binary fraction .011 is evaluated as:

0 × 2−1 + 1 × 2−2 + 1 × 2−3

= 0 + 0.25 + 0.125 = 0.375


Step 4: Add integer and fractional values

2 + 0.375 = 2.375


Final Answer:

2.375

Was this answer helpful?
0