by default radix of parseInt method is 10. so it will convert "123" into integer 123 but if ur dealing with binary number, binary string need to be converted into integer for example "1101" will get converted into 13 which is integer equivalent of 1101
First parameter like x and y are string binary number like "10011". Now to convert into any pattern we can use base. here we have to convert into binary number, so we are using 2. Change 2 into 10 and see what ur getting, then u will understand
Thanks for posting this. It was very helpful and not as complicated as other videos I had previously viewed.
Thank you
Thanks for the explaination.
This was simplified and very helpful. Good teacher!!!
Thank u
Nice and easy solution thanks
Thank u Kiran for ur feedback
Easy solution...
Tnx... 😍
cant we do this code without the use of the wrapper class
WHAT, bro thank you so much I been studying one code to add binary numbers and it so complicated compare to yours.
Good to hear from you
what is the function of parseint and tobinarystring? plz tell
convert a string form into integer like "123" into simply 123
by default radix of parseInt method is 10. so it will convert "123" into integer 123
but if ur dealing with binary number, binary string need to be converted into integer for example "1101" will get converted into 13 which is integer equivalent of 1101
@@MicroNG Ok thanks
Thanks it easy to understand
What happen if we enter decimal number it will check "it is binary or not" OR is throw error
Instead of parseint can we directly input in long data type?
U need to use wrapper class
Very well explained my guy, and your speech is worth listening to for hours😅😂
happy to see ur comment
BINARY ADDITION: Two decimal numbers are accepted as input and are
automatically converted into binary numbers and are added.
How can I help?
@@MicroNG how will be make this type of calculator that I have written this question?
Sir why you are used 2
In the parseint
how about this 102.96 to binary what it is code please help
Awsome!! thanks..
Why the Parameters passed (x,2) and (y,2).. explain plz
First parameter like x and y are string binary number like "10011". Now to convert into any pattern we can use base. here we have to convert into binary number, so we are using 2.
Change 2 into 10 and see what ur getting, then u will understand
You are great dude other videos sucks
Thank you brother
Welcome
@@MicroNG bro fro me error it was showing
Your method is very simplified man. Thanks!! Mine actually sucks
import java.util.Scanner;
public class Main {
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("
");
}
}
Thank u Emmanuel for ur feedback
Not that clear with the explanation, but the code is good.
thank you for ur feedback.
Ye kha pr run krna plz tell me plzzz...
Any jave editor u can use.. here unused NetBeans.. u can use eclipse also
Thanks
Bro its not working
what happened?
smart
Thank YOU
Why Indian :(
sorry i didn't get ?