add two binary numbers in java | java tutorial for beginners

preview_player
Показать описание
Write a Java program to add two binary numbers
#add #binary #number
Комментарии
Автор

WHAT, bro thank you so much I been studying one code to add binary numbers and it so complicated compare to yours.

clarencecho
Автор

Thanks for posting this. It was very helpful and not as complicated as other videos I had previously viewed.

xelgringox
Автор

This was simplified and very helpful. Good teacher!!!

cr
Автор

Very well explained my guy, and your speech is worth listening to for hours😅😂

ishan
Автор

what is the function of parseint and tobinarystring? plz tell

sherrycomm
Автор

What happen if we enter decimal number it will check "it is binary or not" OR is throw error

shunmugarajan
Автор

Instead of parseint can we directly input in long data type?

tanvigupta
Автор

cant we do this code without the use of the wrapper class

Ritik-ioof
Автор

how about this 102.96 to binary what it is code please help

robokop
Автор

Sir why you are used 2
In the parseint

BusinessBookBite
Автор

Not that clear with the explanation, but the code is good.

iamjm_rishav
Автор

BINARY ADDITION: Two decimal numbers are accepted as input and are
automatically converted into binary numbers and are added.

nizam-u-ddinpatoli
Автор

Your method is very simplified man. Thanks!! Mine actually sucks

import java.util.Scanner;

public class Main<remainder> {
public static void main(String[] args) {
long binary1, binary2;
int i = 0;
int remainder = 0;
int sum[] = new int[20];
Scanner pot = new Scanner(System.in);

System.out.println("Print first binary number");
binary1 = pot.nextLong();

System.out.println("Print second binary number");
binary2 = pot.nextLong();
while(binary1!=0 || binary2!=0){
sum[i++]=(int)((binary1 % 10 + binary2 % 10 + remainder) % 2);

remainder = (int)((binary1 % 10 + binary2 % 10 + remainder) / 2);
binary1 = binary1 / 10;
binary2 = binary2 / 10;

}

if (remainder != 0) {
sum[i++] = remainder;
}
--i;
System.out.print("Sum of two binary numbers: ");
while (i >= 0) {
System.out.print(sum[i--]);
}
System.out.print("\n");
}
}

spenceremmanuel
Автор

Why the Parameters passed (x, 2) and (y, 2).. explain plz

bhimeshbhim
Автор

Ye kha pr run krna plz tell me plzzz...

any_farooqui