codinasion-archive / codinasion-monorepo

Community Monorepo
https://codinasion.org
MIT License
52 stars 168 forks source link

[Program]: Write a Kotlin program to convert binary to hexadecimal #749

Open harshraj8843 opened 2 years ago

harshraj8843 commented 2 years ago

Description

Write a Kotlin program to convert binary to hexadecimal

Binary is a base-2 number system. It uses only two digits: 0 and 1. The digits are called bits. A bit is the smallest unit of information in a computer. A bit can be either 0 or 1. A bit can be used to represent a single value, such as 0 or 1, or it can be used to represent a single state, such as on or off.

Hexadecimal is a base-16 number system. It uses sixteen digits: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, and F. The digits are called hexits. A hexit is the smallest unit of information in a computer. A hexit can be used to represent a single value, such as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, or F, or it can be used to represent a single state, such as on or off.

To convert a binary number to hexadecimal, we can use the following algorithm:

  1. Convert the binary number to decimal.
  2. Convert the decimal number to hexadecimal.
Input  : 1010
Output : A
How to contribute - Save the solution in `program/program/convert-binary-to-hexadecimal/ConvertBinaryToHexadecimal.kt` file
gsquareg2 commented 1 year ago

!assign

gsquareg2 commented 3 months ago

!assign