Java code for Converting Decimal Number to Binary Number

  Рет қаралды 13,762

TrainingMug

TrainingMug

6 жыл бұрын

This program demonstrates the logic and code for converting decimal number to binary number
Normal integer number are by default decimal number ( base 10 , which contains digits from 0 to 9), example: 100,34534,-345345.
Every decimal number internally stored as binary number ( base 2, which contains only two digits,i.e. 0 and 1 ).
Converting decimal to binary involves the following steps
1. we need to divide the decimal number by 2 til it reaches to 0
2. In this process we need to store the remainders
3. The remainders must be printed in the reverse order to get the binary representation.
Example : 10 decimal is equivalent to 1010.
In this video session, we have discussed the following approaches to convert decimal to binary
1. Using Integer.toBinaryString(int no) the pre-defined method in Java API
2. Using array to store all the remainders
3. Using String to concatenate all the remainders
If you like this video, don't forget to subscribe , like and share this video
Please promote this channel , by sharing it with your friends who are searching / preparing for IT jobs in programming..
If you have any coding challenges ( questions ) , post them in the comment, we will upload the videos for the same

Пікірлер: 10
@cedrikclaus1940
@cedrikclaus1940 2 жыл бұрын
God bless you my friend took me an hour to find how to do with strings once again indian youtuber comes in clutch
@paralejasjustine2557
@paralejasjustine2557 2 жыл бұрын
Exactly what I needed, thanks!
@simranha4550
@simranha4550 5 жыл бұрын
crystal clear explanation.thank you sir
@MrAmin-pu2lw
@MrAmin-pu2lw 3 жыл бұрын
Thanks for the sake of mankind it helped me thanks again.
@rktechnicalpoint4895
@rktechnicalpoint4895 2 жыл бұрын
God Bless You
@shruthigouda5276
@shruthigouda5276 5 жыл бұрын
clear explanation .....thank u sir
@mohanasundari6188
@mohanasundari6188 3 жыл бұрын
Sir this program understand clearly , i want binary addition , binary multiplication demonstration Sir
@aseeldee.1965
@aseeldee.1965 3 жыл бұрын
Thanks a lot 🙏🙏😁
@mariaalarcon4225
@mariaalarcon4225 3 жыл бұрын
Hello! Thanks a lot for the explanation! I have tried the following but it does not work, I have everytime result = 0. Could you please help me? public class DecimalToDual { public static void main(String[] args) { int decimal = 12; System.out.println("The number is base2 is " + transformToDual(decimal)); } public static String transformToDual(int decimal) { int n = decimal; String binary = ""; //initialize variable binary int remainder = decimal % 2; binary = remainder + binary; //at the beginning the remainder will be concatenated with the empty string (binary) but then it will be start adding nº to it. n = n / 2; return binary; } }
Java code to Convert Binary Number to Decimal Number
11:37
TrainingMug
Рет қаралды 16 М.
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 14 МЛН
Happy 4th of July 😂
00:12
Pink Shirt Girl
Рет қаралды 60 МЛН
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 49 МЛН
Fibonacci Series In Java With Recursion - Full Tutorial (FAST Algorithm)
15:11
How To Convert Decimal to Binary
13:24
The Organic Chemistry Tutor
Рет қаралды 4,4 МЛН
Java code for Printing Multiplication Table from 1 to 10
9:27
TrainingMug
Рет қаралды 12 М.
How to Convert Decimal to Binary
3:20
tecmath
Рет қаралды 401 М.
Learn JSON in 10 Minutes
12:00
Web Dev Simplified
Рет қаралды 3,1 МЛН
How To Think Like A Programmer
1:00:07
Coding Tech
Рет қаралды 2 МЛН
How to print in binary
18:35
CodeVault
Рет қаралды 16 М.
3M❤️ #thankyou #shorts
00:16
ウエスP -Mr Uekusa- Wes-P
Рет қаралды 14 МЛН