- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
10’s Complement of a decimal number?
9’s complement and 10’s complement are used to make the arithmetic operations in digital system easier. These are used to make computational operations easier using complement implementation and usually trade hardware usage to the program.
To obtain the 9’s complement of any number we have to subtract the number with (10n – 1) where n = number of digits in the number, or in a simpler manner we have to subtract each digit of the given decimal number from 9.
10’s complement, it is relatively easy to find out the 10’s complement after finding out the 9’s complement of that number. We have to add 1 with the 9’s complement of any number to obtain the desired 10’s complement of that number. Or if we want to find out the 10’s complement directly, we can do it by following the following formula, (10n – number), where n = number of digits in the number.
Let us take a decimal number 456, 9’s complement of this number will be
999 -456 _____ 543
10’s complement of this no
543 (+)1 ______ 544
Input:456 Output:544
Explanation
Mathematically,
10’s complement = 9’s complement + 1 10’s complement = 10i – num
Where, i = total number of digits in num.
Example
#include <iostream> #include<math.h> using namespace std; int main() { int i=0,temp,comp,n; n=456; temp = n; while(temp!=0) { i++; temp=temp/10; } comp = pow(10,i) - n; cout<<comp; return 0; }
- Related Articles
- 10’s Complement of a decimal number?
- 1’s and 2’s complement of a Binary Number?
- 1's Complement vs 2's Complement
- Draw a Turing machine to find 1’s complement of a binary number
- Draw a Turing machine to find 2’s complement of a binary number
- Design a Moore machine to generate 1's complement of a binary number.
- Previous number same as 1’s complement in C++
- 8085 program to find 1's and 2's complement of 8-bit number
- 8085 program to find 1's and 2's complement of 16-bit number
- 1's complement notation
- 2's complement notation
- 2's complement fractions
- Complement of Base 10 Integer in Python
- How to convert a decimal number to a rational number with denominator to the power of 10?
- Reversing the bits of a decimal number and returning new decimal number in JavaScript
- Decimal count of a Number in JavaScript
