Rock dude
Posted in : Java Beginners

March 20, 2009 at 7:40 AM

Hi Friend,

Try the following code for solving your problem. In this code we have taken first two numbers in two strings and after that we have added them by converting them to binary format.

public class ConvertBinary {

public static void main(String[] argv) {

String str1 = "2";
String str2 = "2";

Integer num1 = new Integer(str1);
Integer num2 = new Integer(str2);

System.out.println("1st binary number : " +
Integer.toBinaryString(num1));
System.out.println("1st binary number : " +
Integer.toBinaryString(num2));

System.out.println("Add into binary : " +
Integer.toBinaryString(num1 + num2));
System.out.println("Add into decimal : " + (num1 + num2));
}
}

Thanks
RoseIndia Team

March 20, 2009 at 7:47 AM

i have already done ths way.please read the query and provide me solution if u can.i need to pass 512 bit number not a single number!and i need to use char array and byte array to convert it.

binary addition,subtraction and modulus operations - Java Beginners
binary addition,subtraction and modulus operations  i wanna perform binary addition,subtraction and modulus operation between two numbers of 512 bit... passed as string into binary form, and then perform addition,subtraction and modulus
Show Addition, Subtraction, Intersection, Exclusive OR on one Frame
Show Addition, Subtraction, Intersection, Exclusive OR on one Frame       This section illustrates you how to show Addition, Subtraction, Intersection, ExclusiveOR on one
Show Addition, Subtraction, Intersection, Exclusive OR on one frame
Show Addition, Subtraction, Intersection, Exclusive OR on one frame       This section illustrates you how to show Addition, Subtraction, Intersection, ExclusiveOR on one frame
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........
code for a simple java program which performs basic arithmetic operation addition,subtraction,multiplication,division........  code for a simple java program which performs basic arithmetic operation addition,subtraction
PHP Arithmetic Operator
Arithmetic operator is used to perform addition(+), subtraction(-), Division(/), Multiplication(*), modulus(%). with variable or value. We all have done in our...;"; ?> Output: -12 12 13 13 11 Example (Binary operator
Retrive data from database and perform binary tree operations on that data in jsp or java
Retrive data from database and perform binary tree operations on that data in jsp or java  To develop code for MLM project. I want to retrieve data from database dynamically and perform operations on that. Just like calculate
Arithmetic Operators
operations like addition, subtraction, multiplication, division, and modulo...; n + 1;  - Subtraction Operator  n =  n - 1...:\nisha>java ArithmeticDemo The addition of (x + y): 10
JSP Modulus
JSP Modulus          JSP Modulus is used to determine the modulus of number in jsp. Modulus is the remainder of division operation. Understand
binary
binary  Hi I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. Thks
Operators
certain tasks like addition, subtraction etc. Simple Assignment Operator = ...; Operators are symbols that performs some operations on one or more than one operands...; Subtraction operator *  Multiplication operator /   Division
Operators
certain tasks like addition, subtraction etc. Simple Assignment Operator = ...; Operators are symbols that performs some operations on one or more then one operands...; Subtraction operator *  Multiplication operator /   Division
MySQL Modulus
MySQL Modulus       MySQL Modulus refer to the remainder value obtained when a value 'a' is divided... Modulus'. To understand and elaborate the example we create a table 'oddeven
Operations on string
Operations on string  Apply undo,redo operations on String pool in java
Operations with Calendar
Operations with Calendar  I have the following as my known parameter Effective Date : 21-08-2012 Cut off day : Thursday I want my first cycle calculation done from 21-08-2012 till wednesday(22-08-2012) and from thursday my
Binary tree
Binary tree  a. Construct a method to implement a binary tree using an array. b. Implement the binary tree to store numbers in sorted order
Binary tree
Binary tree  hii, What is binary tree?   hello, A binary tree is a tree in which every node has exactly two links i.e left and right link
binary tree
binary tree  can a binary tree be implemented with out comparing...://www.roseindia.net/java/java-get-example/java-binary-tree-code.shtml http://www.roseindia.net/java/java-get-example/java-binary-tree-insert.shtml
binary tree
binary tree  how to count no. of nodes in a binary tree for mlm if it complet tree or incomplet tree in php using mysql db
octal to binary
octal to binary  i want to know how to convert a octal to binary number   Here is a java example that converts octal to binary. import... binary=Integer.toBinaryString(i); System.out.println(binary
program binary
program binary  Hi I want to write a program in pascal that ask a user to input a decimal number and then return its binary equivalent in the minimum number of bits required to repesent the number. In pascal language please
Binary Search - Java Beginners
Binary Search  how to use Binary think in java give me the Binary Search programm thx
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
universal binary for ipad iphone  How can i create a universal binary for iPad and iPhone
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
binary search program
binary search program  write a program to searching a string using binary search
crud operations with foreign key constraint.
crud operations with foreign key constraint.  I neeed to know how to perform crud operations in mysql with foreign key constraint using mvc architecture i.e using servlet jsp and bean. please provide all the code so that i can
CRUD operations in spring mvc 2.5
CRUD operations in spring mvc 2.5  Hi, I want to do CRUD operations on jquery datatable such as edit delete select and add row. I am using spring mvc 2.5. How can I do this. Thanks in advance
MySQL Arithmetic
. Arithmetic operators are used to perform mathematical operations on two expressions... + Addition - Subtraction * Multiplication
swing program for decimal to binary
swing program for decimal to binary  swing program for decimal to binary
Tutorials