Number System Conversions
Rashik Ansar
Rashik NotesConvert a number from one number system to another number system.
#
Number SystemIn computer science we might have come across various number systems like binary, octal, decimal and hexadecimal. Everything in the memory is stored in binary form whenever we print address of a variable the compiler will print address in hexadecimal format.
#
Conversion between two number systemsGiven a number in x
number system (input number sytem or given number system) and want them it in y
number system (output number sytem or expected number system). The more generalized algorithm but it'll work only for those number systems whose base that is less than or equal to the decimal number system (example: It'll not work hexadecimal system since it has characters in it and it'is greater than 10).
#
ExamplesBinary to Decimal number conversion using the same algorithm but with in the main function itself. We can try with various number systems where we just have to change the GIVEN_NUMBER_SYSTEM
and EXPECTED_NUMBER_SYSTEM
values.
Another example with Decimal to Octal