Home Answers Viewqa Java-Beginners binary addition,subtraction and modulus operations

 
 


Rock dude
binary addition,subtraction and modulus operations
2 Answer(s)      4 years and 2 months ago
Posted in : Java Beginners

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 Pages:
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
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
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
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
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
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
MySQL Arithmetic
. Arithmetic operators are used to perform mathematical operations on two expressions... + Addition - Subtraction * Multiplication
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
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
Java Convert decimal to binary using Stacks
Java Convert decimal to binary using Stacks In this section, you will learn how to convert decimal into binary using stacks. You all are aware of Stacks. It performs two basic operations push and pop. The push operation adds an element
String Number Operations in JavaScript
String Number Operations in JavaScript  ... numeric addition and string concatenation. which the nature of the operation... to start with the + operator perform addition. Otherwise it converts all of its
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
Java
Java  java program to get output on the basis of users choice of switch statement perform operations addition, subtraction and multiplication of matrix
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
The Arithmetic Operators
that perform the mathematical values addition, subtraction, multiplication...;   }   public int Addition(){   ...(object.readLine());   int addition=arithmeticOperator.Addition
Binary Search - Java Beginners
Binary Search  how to use Binary think in java give me the Binary Search programm thx
PHP Mathematical Operation
Mathematical Operations in PHP PHP supports mathematical operations as other languages do. It support addition, subtraction, division, multiplication...;; ?> Output: Addition of 25 and 5 is=30 Subtraction of 25 and 5 is=20
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
binary search program
binary search program  write a program to searching a string using binary search
swing program for decimal to binary
swing program for decimal to binary  swing program for decimal to binary
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 search tree
binary search tree  Construct a binary search tree by inserting the following sequence of characters into an empty tree. N O N L I N E A R D A T A Visit the tree using all three traversal algorithms and list the output sequence
binary search tree
binary search tree  Construct a binary search tree by inserting words into an empty tree. "cut your coat according to your cloth" Visit the tree using all three traversal algorithms and list the output sequence for each algorithm
Hibernate Performing the usual DB operations
HIBERNATE-BASICS Hibernate Performing the usual DB operations... the usual DB operations. Hybernate2 can be downloaded from http... program with 4 buttons for add, modify, delete and find operations. We can call
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
java binary file io example
java binary file io example  java binary file io example
Binary to decimal - Java Beginners
Binary to decimal  Need help pls.. i cannot run this program... pls... = Integer.parseInt(JOptionPane.showInputDialog("Input Binary:")); String c = args[0...; String value = JOptionPane.showInputDialog("Input Binary"); int len
Binary Search Tree
Binary Search Tree  Question-1 ) Modify the BinarySearchTree class so that the iterators are fail-fast.Test your class with amain method ? Question-2 ) Modify the BinarySearchTree class so that the BinarySearchTree objects

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.