10's Complement of a decimal number?

The 10's complement of a decimal number is a mathematical operation used in digital systems to simplify arithmetic operations, particularly subtraction. It is calculated by subtracting the given number from 10n, where n is the total number of digits in the number.

The 10's complement can be found in two ways −

  • Method 1: Calculate 9's complement first, then add 1
  • Method 2: Direct calculation using formula: 10n - number

Syntax

int tensComplement = pow(10, digitCount) - number;

Method 1: Using 9's Complement

First find the 9's complement by subtracting each digit from 9, then add 1 −

#include <stdio.h>
#include <math.h>

int countDigits(int num) {
    int count = 0;
    while (num != 0) {
        count++;
        num = num / 10;
    }
    return count;
}

int ninesComplement(int num, int digits) {
    int maxNum = pow(10, digits) - 1;
    return maxNum - num;
}

int main() {
    int number = 456;
    int digits = countDigits(number);
    
    printf("Original number: %d
", number); int ninesComp = ninesComplement(number, digits); printf("9's complement: %d
", ninesComp); int tensComp = ninesComp + 1; printf("10's complement: %d
", tensComp); return 0; }
Original number: 456
9's complement: 543
10's complement: 544

Method 2: Direct Calculation

Using the direct formula: 10n - number −

#include <stdio.h>
#include <math.h>

int main() {
    int number = 456;
    int temp = number;
    int digitCount = 0;
    
    /* Count digits */
    while (temp != 0) {
        digitCount++;
        temp = temp / 10;
    }
    
    /* Calculate 10's complement directly */
    int tensComplement = pow(10, digitCount) - number;
    
    printf("Number: %d
", number); printf("Number of digits: %d
", digitCount); printf("10's complement: %d
", tensComplement); return 0; }
Number: 456
Number of digits: 3
10's complement: 544

How It Works

For number 456 (3 digits) −

  • 103 = 1000
  • 10's complement = 1000 - 456 = 544

Key Points

  • 10's complement = 9's complement + 1
  • Direct formula: 10n - number
  • Used in binary arithmetic for efficient subtraction
  • Always results in a number with the same number of digits

Conclusion

The 10's complement is a fundamental concept in digital arithmetic that simplifies subtraction operations. Both methods yield the same result, with the direct approach being more efficient for programming implementation.

Updated on: 2026-03-15T11:35:16+05:30

3K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements