Number System in C: Examples
Basics of Number System
We have studied previously about Number systems in C.
- A number system is a system of writing for expressing numbers. It is the mathematical notation for representing numbers of a given set by using digits or other symbols in a consistent manner.
- It provides a unique representation to every number and represents the arithmetic and algebraic structure of the figures. It also allows us to operate arithmetic operations like addition, subtraction, and division.
- The language we use to communicate with each other is comprised of words and characters. We understand numbers, characters and words. But this type of data is not suitable for computers. Computers only understand the numbers is called number system.
- Ex :- The counting numbers (1, 2, 3, …) together with the operations of addition, subtraction, multiplication, and division and the properties they satisfy.
1. Decimal to Another base system( binary , octal, hexadecimal )
- To convert a Decimal number into any other base we first have to divide the given number by the base of the target base system such as [2] in case of binary system, [8] in the case of octal system, [16] in case of hexadecimal.
- The remainder obtained in the first step of division is written as LSB (least significant bit) until the last step, which will be written as MSB( most significant bit).
- Write the remainder obtained in the reverse order to obtain the converted result.
