Skip to content

Syllabus · CS Computer Science and Information Technology

All topics in this subject
C programming foundations6
Arrays and pointers7
Recursion6
Probability and statistics foundations9
Linked lists, stacks and queues3
Trees, BSTs and heaps3
Graph foundations3
Algorithms foundations3
Discrete mathematics foundations15
Digital logic foundations22
Computer organization foundations12
Operating systems foundations6

Floating-point arithmetic alignment and rounding

Lesson 62 of 959 minFree

Exact mathematics followed by a format decision

Floating-point arithmetic does not mean manipulating exponent fields like ordinary binary integers. A useful model is: obtain the exact mathematical result, then round once to the destination format under the specified mode. Implementations use extra information to reproduce this result without needing infinitely many stored digits.

Prerequisites: binary fractions and the seven-bit floating format from the preceding lesson. We retain sign s, three exponent bits with bias 3, three stored fraction bits, normal precision p=4, normal range 1/4…15 in positive magnitude and subnormal steps of 1/32. Our numerical worked examples remain within the finite range. They use round to nearest, ties to even after every stated operation, with no hidden extra precision or fused operation. This is an educational arithmetic contract, not a claim about an arbitrary programming language's evaluation rules.

Nearest ties to even

Choose the representable neighbor nearest to the exact result. At an exact midpoint choose the neighbor whose retained significand integer has an even least significant bit. For subnormals, use the stored fraction integer. The sign does not mean always rounding negative values downward; nearest rounding minimizes distance on either side of zero.

Worked example 1: in [1,2), representable values are separated by 1/8. The exact value 1.0625 lies halfway between 1.000₂=1 and 1.001₂=1.125. Their retained four-bit significand integers are 8 and 9, so choose even 8: result 1. The midpoint 1.1875 instead lies between 1.125 (integer 9) and 1.25 (integer 10), so choose 1.25. “Round a tie upward” is not the same policy.

Rounding may carry into a new exponent. For example 1.9375 is halfway between 1.875 and 2. The retained units on the lower binade's grid are 15 and 16; even 16 selects 2, which is normalized as 1.000₂×2¹. Recheck the exponent after rounding, not just after the initial arithmetic.

Addition aligns binary points

For normal operands, express both with a common exponent, usually the larger exponent, by right-shifting the smaller significand while preserving enough low-bit information. Then add signed significands, normalize as needed, round, and check range/classification. An exponent difference is a shift count, not an instruction to add the exponents during addition.

Worked example 2: 1.5+0.375. Write 1.5=1.100₂×2⁰ and 0.375=1.100₂×2^−2. Align to exponent zero: 1.10000₂+0.01100₂=1.11100₂. This is 1.875, exactly representable as 1.111₂×2⁰. The exponent stays zero because the result is below 2.

Worked example 3: 1+0.09375. The second value is representable as subnormal 3/32. On a common exact scale, 1.00000₂+0.00011₂=1.00011₂=1.09375. At p=4 the neighbors are 1 and 1.125; distances are 0.09375 and 0.03125, so the rounded result is 1.125. Dropping all low bits before deciding would incorrectly produce 1. The second operand is small, but not too small to affect rounding.

Guard round and sticky information

After the retained significand bits, call the next bit G (guard), the following bit R (round), and the OR of all remaining discarded bits S (sticky). Let L be the retained least significant bit. For nearest ties-to-even, increment the retained magnitude exactly when G=1 and at least one of R,S,L is 1. If G=0 the discarded tail is below half. If G=1,R=S=0 it is an exact tie, and L determines evenness.

For 1.00011₂ at p=4, retained bits are 1.000, G=1,R=1,S=0; increment to 1.001. For 1.00010₂, G=1,R=0,S=0 and L=0, so keep 1.000. Sticky is the OR of the entire remaining tail, not just its last bit. These definitions explain final rounding; a complete arithmetic unit must also preserve the necessary information through alignment, subtraction and normalization.

Subtraction and cancellation

Subtract by adding the signed opposite, but retain enough information while leading bits cancel. Worked example 4: 1.5−1.375=1.100₂−1.011₂=0.001₂=0.125. In our format this is exactly subnormal 0|000|100 because 4/32=0.125. A result below the normal threshold is not necessarily zero or inexact.

Cancellation removes leading significant bits and may make prior input error more prominent relative to the small answer. It does not mean every subtraction of close numbers is incorrectly rounded; the exact example above is correct. Distinguish loss of information already present in rounded operands from rounding of the current operation.

Near zero, nearest rounding still compares actual neighbors. The exact 1/64 is halfway between zero and the smallest subnormal 1/32. Their fraction integers are 0 and 1, so ties-to-even selects zero. The exact 3/64 is halfway between 1/32 and 2/32; even 2 selects 1/16. These examples are tiny and inexact; an exact representable subnormal such as 1/8 is different.

Multiplication and division

For normal multiplication, multiply significands and add true exponents, then normalize and round. If using encoded exponents, E_out=E_a+E_b means e_out=e_a+e_b−bias before normalization adjustments. Adding both biases without removing one is wrong. Product sign is the XOR of operand sign bits for nonzero finite values.

Worked example 5: 1.625×1.375=(13/8)(11/8)=143/64=2.234375. In the [2,4) binade spacing is 1/4. The nearest values are 2 and 2.25, with distances 15/64 and 1/64, so the result is 2.25. This is 1.001₂×2¹; normalization and rounding must both be considered.

For normal division, divide significands and subtract true exponents, then normalize and round. For example 1/3 is not a terminating binary fraction. In this format its neighboring values are 10/32=0.3125 and 11/32=0.34375. Their distances from 1/3 are 1/48 and 1/96, so nearest rounding gives 11/32. Do not infer that dividing two representable values must produce an exact representable value.

Rounding changes algebraic behavior

Worked example 6 uses a=8,b=0.5,c=−8, all representable. With rounding after each operation, a+b=8.5 is a tie between 8 and 9; even significand chooses 8. Thus (a+b)+c=0. But b+c=−7.5 exactly, so a+(b+c)=0.5 exactly. Floating addition is not associative under this contract, despite real-number addition being associative.

Similarly, computing a product and rounding before an addition is not necessarily the same as a fused multiply-add that rounds only once. Do not mix evaluation contracts while comparing results.

Exceptions and a final checklist

If an exact magnitude exceeds the available finite range, report a range/rounding issue and apply the specifically chosen overflow-mode rule; blindly truncating exponent bits is not floating-point overflow handling. In IEEE-style arithmetic, infinity and NaN have separate rules: an invalid form such as 0/0 is not ordinary finite division, and infinity is not the same as NaN. Full exception flags, signaling NaNs and trap handling are beyond this lesson.

Write the format and rounding mode; classify operands; align for addition or combine true exponents for multiplication/division; preserve low-bit information; normalize; round; renormalize if rounding carries; classify/check the result. Validate small cases with exact fractions, not decimal displays from another unspecified floating format.

Original practice

These six single-correct MCQs are original learning questions, not previous-year questions. Choose exactly one option.

C01. In the p=4 educational format, round exact 1.0625 to nearest ties-to-even. What is the result?

A. 1.125 B. 1 C. 1.0625 exactly D. 0.9375

Answer: B

A is incorrect: it chooses the odd retained significand at this tie.

B is correct: the midpoint neighbors have significand integers 8 and 9; even 8 gives 1.

C is incorrect: four significant bits cannot store 1.0001₂ exactly.

D is incorrect: it is not one of the two nearest neighbors.

C02. Using the same format and rounding mode, what is the rounded sum 1+0.09375?

A. 1 B. 1.25 C. 1.125 D. 0.09375

Answer: C

A is incorrect: exact 1.09375 is closer to 1.125 than to 1.

B is incorrect: 1.25 is farther away than the immediate upper neighbor.

C is correct: distances to 1 and 1.125 are 0.09375 and 0.03125.

D is incorrect: this omits the first operand entirely.

C03. With retained least significant bit L and discarded bits G,R,S, which condition increments for nearest ties-to-even?

A. G AND (R OR S OR L) B. G always, regardless of other bits C. R AND S only D. NOT G

Answer: A

A is correct: tails above half round up; exact ties increment only an odd retained value.

B is incorrect: G=1,R=S=L=0 is a tie whose retained value is already even.

C is incorrect: it misses exact ties with odd L and many above-half tails.

D is incorrect: G=0 means the tail is below half.

C04. The educational format has subnormal step 1/32. What does exact 3/64 round to under nearest ties-to-even?

A. 0 B. 1/32 C. 3/64 exactly D. 1/16

Answer: D

A is incorrect: zero is farther away than either adjacent positive candidate.

B is incorrect: fraction integer 1 is odd at the midpoint.

C is incorrect: 3/64 is half an odd number of subnormal steps, not an encoding.

D is correct: the tie is between fraction integers 1 and 2; choose even 2, giving 2/32=1/16.

C05. In this format, with rounding after each addition, a=8,b=0.5,c=−8. Which pair gives ((a+b)+c, a+(b+c))?

A. 0.5, 0.5 B. 0, 0.5 C. 0, 0 D. 0.5, 0

Answer: B

A is incorrect: a+b=8.5 rounds to even-significand 8, losing b in that grouping.

B is correct: the left grouping gives 8−8=0; b+c=−7.5 exactly, so the right gives 0.5.

C is incorrect: the right grouping remains exact at both operations.

D is incorrect: it reverses which grouping loses the small contribution.

C06. For normal multiplication with exponent bias B, what is the encoded output exponent before normalization adjustments, assuming no special fields?

A. e_a+e_b B. e_a−e_b+B C. e_a+e_b−B D. e_a+e_b−2B

Answer: C

A is incorrect: it retains one excess bias.

B is incorrect: this is the exponent relation for division before normalization.

C is correct: true exponents add to e_a+e_b−2B; adding destination bias gives e_a+e_b−B.

D is incorrect: this is the sum of true exponents, not the encoded exponent.

Scope and sources

This is one bounded Digital Logic lesson, not complete GATE CS coverage. The official syllabus establishes relevance only; the derivations, examples and practice are original. Technical references were used to check representation and circuit conventions, not to reproduce their exercises.

Sources checked 14 October 2026.

Sign in to keep your progress. Sign in