ITエンジニアが仕事に対して思うこと

ITエンジニアとして働く中で感じたことを、現場の温度感そのままに言語化するブログです。設計・実装・運用のリアル、学び続ける負荷、品質とスピードのせめぎ合い、コミュニケーションの難しさなど、きれいごとだけでは語れない「仕事の実態」を整理します。誰かを責めるのではなく、なぜそうなるのかを構造で捉え、明日から少し楽に、少し強く働ける視点を提供します。新人から中堅、マネジメントまで参考に。

【動画解説】ITPEC April 2025 FE (Fundamental IT Engineer) Subject B Q4| Step-by-Step Explanation

            [https://www.youtube.com/watch?v=eaPAUYoM-r0:embed:cite]

The program described in Q4 defines a function convert(number) that interprets an integer made only of the digits 0 and 1 (for example, 1100) as a binary representation and returns its decimal value (for example, 12). The core idea is to scan the binary digits from right to left, because the rightmost digit corresponds to the least significant bit with weight 2⁰, and each step to the left doubles the weight. At the beginning, decimal is initialized to 0 so it can accumulate the total, place is initialized to 1 to represent the current bit weight (starting at 2⁰), and n is set to number so the original input can be processed digit by digit. The loop runs while n remains positive. In each iteration, remainder ← n mod 10 extracts the rightmost digit of the decimal-form input, which is guaranteed to be 0 or 1. Then n ← integer part of (n ÷ 10) removes that rightmost digit, shifting the next binary digit into position for the next iteration. The conversion step must add the contribution of the current bit to decimal. Since the current digit is remainder and its weight is place, the added amount is remainder × place. That means blank A must be remainder × place, because the update is effectively decimal ← decimal + (remainder × place). After handling one bit, the next bit to the left has twice the weight in binary, so place must be updated by doubling it. Therefore blank B must be 2 × place, corresponding to place ← place × 2. If you walk through an input like 1100, the first remainder is 0 with place 1, so decimal stays 0 and place becomes 2. The next remainder is 0 with place 2, so decimal stays 0 and place becomes 4. The next remainder is 1 with place 4, so decimal becomes 4 and place becomes 8. The last remainder is 1 with place 8, so decimal becomes 12, and the loop ends when n becomes 0. With A set to remainder × place and B set to 2 × place, the completed logic matches choice g, and the function correctly performs binary-to-decimal conversion.