473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

java code to add two numbers using bitwise operators

please tell me java code to add two numbers with using bitwise operators only? can we write the program in java OS is linux, java5.0 version
Aug 18 '07 #1
10 3535
prometheuzz
197 Expert 100+
please tell me java code to add two numbers with using bitwise operators only? can we write the program in java OS is linux, java5.0 version
Even without if-statements or the likes? Only bit-operations? Why not just use the + operator?
Aug 18 '07 #2
JosAH
11,448 Expert 8TB
please tell me java code to add two numbers with using bitwise operators only? can we write the program in java OS is linux, java5.0 version
You might give it a try by googling for "bitwise Horsmeier" *ahem*. That twit
can't write one normal readable statement; everything he types is unreadable,
terse, cryptic gibberish.

kind regards,

Jos ;-)
Aug 18 '07 #3
prometheuzz
197 Expert 100+
You might give it a try by googling for "bitwise Horsmeier" ...
Bit-voodoo!
; )

......
Aug 19 '07 #4
JosAH
11,448 Expert 8TB
Bit-voodoo!
; )

......
I agree; that guy is a nutcase.

kind regards,

Jos ;-)
Aug 19 '07 #5
prometheuzz
197 Expert 100+
I agree; that guy is a nutcase.

kind regards,

Jos ;-)
Oh, no doubt about it!
; )
Aug 19 '07 #6
JosAH
11,448 Expert 8TB
Oh, no doubt about it!
; )
Ok, so we both agree on that; case closed; *grmph*

kind regards,

Jos ;-)
Aug 19 '07 #7
prometheuzz
197 Expert 100+
Ok, so we both agree on that; case closed; *grmph*

kind regards,

Jos ;-)
My mother always warned me not to disagree with mathematicians!
; )
Aug 19 '07 #8
r035198x
13,262 8TB
I disagree of course.
Everything is binary.
Aug 20 '07 #9
praveen2gupta
201 100+
please tell me java code to add two numbers with using bitwise operators only? can we write the program in java OS is linux, java5.0 version
Hi
The bitwise operator will convert your binary number in to equivalent binary number after that it will add the numbers using binary addition norms. and then will convert in to equivalent decimal number. The result will be different from your mathematical addition.
Aug 20 '07 #10
JosAH
11,448 Expert 8TB
Hi
The bitwise operator will convert your binary number in to equivalent binary number after that it will add the numbers using binary addition norms. and then will convert in to equivalent decimal number. The result will be different from your mathematical addition.
Well, I'd say the algorithm used for the addition is incorrect then. When I'd add
the numbers 23 and 19 I'd expect 42 and nothing else, no matter the radix of
the representation of the number.

kind regards,

Jos
Aug 20 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mike Hodkin | last post by:
As a beginning student of C++, books reference "bitwise operators" and give brief examples, but I have not read a good explanation of what they are used for. One reference mentioned that they are...
10
by: August Derleth | last post by:
Cause I made such a hash of my first attempt, and in an effort to provide PORTABLE code to solve the problem, I submit this solution to convert to and from BCD values stored in longs. This should...
5
by: noridotjabi | last post by:
I'm learning to program in C and any tutorial or book that I read likes to briefly touch on birdies operators and then move on without giving any sort of example application of them. Call me what...
9
by: CptDondo | last post by:
I'm working with some legacy C code. Apparently the author didn't know or care about the difference between int, int16_t, unsigned int, and so on. He does a lot of bitwise |, &, etc on signed...
1
by: elsa | last post by:
hi.. im trying to build a program using arrays to do the following things: 1- convert a digital number to binary using mathematical operators by using the function void...
2
by: sudha30 | last post by:
hi please find code to add two numbers only by using bitwise operators
2
by: mahi543 | last post by:
can we write a program in java using bitwise operators to add two numbers
5
by: r035198x | last post by:
Setting up. Getting started To get started with java, one must download and install a version of Sun's JDK (Java Development Kit). The newest release at the time of writting this article is...
7
by: Jeff.Goldfinkle | last post by:
Hi All Is there a simple way to twiddle the bits of a float? In particular, I would like to round my float to the n most significant bits. For example - 0.123 in binary is 0.000111111...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.