binary addition,subtraction and modulus operations

binary addition,subtraction and modulus operations

View Answers

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));
}
}

We hope that the above code will help you.

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.









Related Tutorials/Questions & Answers:
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 frame
Advertisements
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
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
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
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 ADS_TO_REPLACE_5 Example (Binary operator
Arithmetic Operators
operations like addition, subtraction, multiplication, division, and modulo...; n + 1;  - Subtraction Operator  n =  n - 1... ArithmeticDemo.java C:\nisha>java ArithmeticDemo The addition
ModuleNotFoundError: No module named 'modulus'
ModuleNotFoundError: No module named 'modulus'  Hi, My Python... 'modulus' How to remove the ModuleNotFoundError: No module named 'modulus... to install padas library. You can install modulus python with following command
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... from 'MySQL Modulus'. To understand and elaborate the example we create a table
Operations on string
Operations on string  Apply undo,redo operations on String pool in java
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
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  hii, What is binary tree?   hello,ADS_TO_REPLACE_1 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
ModuleNotFoundError: No module named 'Operations'
ModuleNotFoundError: No module named 'Operations'  Hi, My Python... 'Operations' How to remove the ModuleNotFoundError: No module named 'Operations' error? Thanks   Hi, In your python environment you
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
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
universal binary for ipad iphone
universal binary for ipad iphone  How can i create a universal binary for iPad and iPhone
ModuleNotFoundError: No module named 'binary'
ModuleNotFoundError: No module named 'binary'  Hi, My Python... 'binary' How to remove the ModuleNotFoundError: No module named 'binary'... to install padas library. You can install binary python with following command
swing program for decimal to binary
swing program for decimal to binary  swing program for decimal to binary
ModuleNotFoundError: No module named 'list_operations'
ModuleNotFoundError: No module named 'list_operations'  Hi, My... named 'list_operations' How to remove the ModuleNotFoundError: No module named 'list_operations' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'logion-operations'
ModuleNotFoundError: No module named 'logion-operations'  Hi, My... named 'logion-operations' How to remove the ModuleNotFoundError: No module named 'logion-operations' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'logion-operations'
ModuleNotFoundError: No module named 'logion-operations'  Hi, My... named 'logion-operations' How to remove the ModuleNotFoundError: No module named 'logion-operations' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'make-operations'
ModuleNotFoundError: No module named 'make-operations'  Hi, My... named 'make-operations' How to remove the ModuleNotFoundError: No module named 'make-operations' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'make-operations'
ModuleNotFoundError: No module named 'make-operations'  Hi, My... named 'make-operations' How to remove the ModuleNotFoundError: No module named 'make-operations' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'matrix-operations'
ModuleNotFoundError: No module named 'matrix-operations'  Hi, My... named 'matrix-operations' How to remove the ModuleNotFoundError: No module named 'matrix-operations' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'rpaframework-operations'
ModuleNotFoundError: No module named 'rpaframework-operations'  Hi...: No module named 'rpaframework-operations' How to remove the ModuleNotFoundError: No module named 'rpaframework-operations' error? Thanks   
ModuleNotFoundError: No module named 'text_operations'
ModuleNotFoundError: No module named 'text_operations'  Hi, My... named 'text_operations' How to remove the ModuleNotFoundError: No module named 'text_operations' error? Thanks   Hi, In your python
ModuleNotFoundError: No module named 'Complex-Operations'
ModuleNotFoundError: No module named 'Complex-Operations'  Hi, My... named 'Complex-Operations' How to remove the ModuleNotFoundError: No module named 'Complex-Operations' error? Thanks   Hi, In your
ModuleNotFoundError: No module named 'dist-operations'
ModuleNotFoundError: No module named 'dist-operations'  Hi, My... named 'dist-operations' How to remove the ModuleNotFoundError: No module named 'dist-operations' error? Thanks   Hi, In your python
MySQL Arithmetic
. Arithmetic operators are used to perform mathematical operations on two expressions... Definition + Addition - Subtraction
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
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
Binary Search on array
Binary Search on array  What requirement is placed on an array, so that binary search may be used to locate an entry? â?º The array elements must form a heap. â?º The array must have at least 2 entries. â?º The array must
BINARY TO DECIMAL - Java Beginners
BINARY TO DECIMAL  HELP ME PLSS. PROGRAM THAT CONVERTS BINARY TO DECIMAL  Hi friend, Program to convert Binary To Decimal : import... (System.in); System.out.print ("Enter a binary number "); String str
Java read binary file
Java read binary file  I want Java read binary file example code that is easy to read and learn. Thanks   Hi, Please see the code at Reading binary file into byte array in Java. Thanks   Hi, There is many
binary distributions - Java Server Faces Questions
binary distributions  what are binary distributions
Parsing Binary Data in PHP - PHP
Parsing Binary Data in PHP  Is there a better library for working with binary data in PHP
send Binary Data by doGet or doPost?
send Binary Data by doGet or doPost?  which method in doGet or doPost is use to send binary date to server

Ads