IAE Academy

Number systems formulas

Number systems and codes. 19 formulas for GATE EC, EE, IN Digital Electronics, each with when to use it. Each is explained in the topic notes.

All 19 Number systems formulas

VALUE OF A POSITIONAL NUMBER

Here is the number of integer digits and the number of fraction digits . Every digit must be smaller than the base.

RANGE OF AN N-DIGIT UNSIGNED INTEGER; DIGITS NEEDED

An -digit base- integer takes distinct values. In bits, . For example, 256 needs 9 bits because . The formula needs ; the value 0 still takes one digit.

R'S AND (R − 1)'S COMPLEMENTS OF AN N-DIGIT BASE-R NUMBER

is an -digit base- integer (leading 0s count towards ). The 's complement replaces every digit by ; adding 1 to it gives the 's complement. For the 's complement has digits; dropping the extra digit leaves 0. If also has fraction digits, its 's complement is . Examples: the 9's and 10's complements of are and ; the 7's and 8's complements of are and . With these are the 1's and 2's complements.

VALUE OF AN N-BIT 2'S-COMPLEMENT WORD

The MSB has weight . Equivalently, when the MSB is 1, value (unsigned value) . For example, .

RANGES FOR N BITS

For : unsigned is 0 to 255, 2's complement is to , and the other two are to (each has two codes for zero).

NEGATION (COMPLEMENT) RULES

and the results are read as -bit unsigned values, and the carry out of bit is dropped (the arithmetic is modulo ). So in 2's complement, negating gives back; in 1's complement it gives , the second code for zero. In 2's complement, negating gives back (an overflow), because has no -bit code.

SIGNED (2'S-COMPLEMENT) OVERFLOW FLAG

Overflow occurs exactly when the carry into the MSB differs from the carry out of it. This holds for addition and for alike.

OVERFLOW FROM THE SIGN BITS

and are the sign bits of the two words entering the adder, and is the sign bit of the sum. In words: two operands of the same sign produced a sum of the other sign. Adding operands of opposite signs can never overflow. For , use the sign bit of , the word the adder actually receives.

UNSIGNED CARRY AND BORROW

When is computed as , means (no borrow) and means .

BINARY TO GRAY

Equivalently, , where is shifted right by one bit with a 0 entering at the MSB. It takes XOR gates and involves no carries. Example: gives .

GRAY TO BINARY

Work from the MSB down. Each binary bit is the XOR of the Gray bit at that position with the binary bit just found on its left. Equivalently, is the parity of all Gray bits from the MSB down to position .

SINGLE PRECISION: NORMALIZED VALUE

, where is the fraction MSB. The true exponent runs from to .

SINGLE PRECISION: DENORMAL (SUBNORMAL) VALUE

There is no hidden 1, and the exponent is fixed at , not . Denormals fill the gap between 0 and the smallest normalized number in equal steps of .

LARGEST AND SMALLEST POSITIVE SINGLE-PRECISION VALUES

has and all 1s (hex 7F7FFFFF). has , (hex 00800000). has and (hex 00000001). The negative values mirror these with .

SPACING OF NORMALIZED NUMBERS

The gap doubles with each power of 2. Absolute resolution therefore worsens as magnitude grows, while the relative gap between neighbours stays between and . Below the denormals take over, with the fixed gap .

EXPONENT BIAS; DOUBLE PRECISION

is the number of exponent bits: gives 127 and gives 1023. Double precision has 1 sign bit, 11 exponent bits and 52 fraction bits, and its denormals use . A question that defines its own format, with a stated bias or a different significand convention (for example with no hidden bit), overrides these values.

PARITY BIT

To check, XOR all received bits; with even parity, a result of 1 flags an error. An XOR tree with inputs needs two-input XOR gates.

MINIMUM DISTANCE OF A CODE

is the smallest number of bit positions in which any two valid code words differ. To correct up to errors and also detect up to errors (), . Single parity has , so it detects 1 error and corrects none.

CHECK BITS FOR A SINGLE-ERROR-CORRECTING HAMMING CODE

is the number of data bits and the number of check bits, and you take the smallest that satisfies the inequality. needs (the (7,4) code) and needs . needs , not 4, because . In the usual layout the check bits sit at positions 1, 2, 4, 8, … (numbered from 1), and the recomputed checks (the syndrome), read as a binary number, give the position of a single flipped bit, with 0 meaning no error. The Hamming code has ; adding one overall parity bit raises it to 4, so the extended code corrects 1 error and detects 2.

Where this was asked: 2018 (1), 2020 (1), 2024 (1), 2025 (1), 2026 (1). See the 5 previous-year questions on Number systems. This shows what was asked, not what will be asked.