java code to add two numbers using bitwise operators

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mahi543
    New Member
    • Aug 2007
    • 5

    #1

    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
    Last edited by mahi543; Aug 18 '07, 02:20 PM. Reason: modify
  • prometheuzz
    Recognized Expert New Member
    • Apr 2007
    • 197

    #2
    Originally posted by mahi543
    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?

    Comment

    • JosAH
      Recognized Expert MVP
      • Mar 2007
      • 11453

      #3
      Originally posted by mahi543
      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 ;-)

      Comment

      • prometheuzz
        Recognized Expert New Member
        • Apr 2007
        • 197

        #4
        Originally posted by JosAH
        You might give it a try by googling for "bitwise Horsmeier" ...
        Bit-voodoo!
        ; )

        ......

        Comment

        • JosAH
          Recognized Expert MVP
          • Mar 2007
          • 11453

          #5
          Originally posted by prometheuzz
          Bit-voodoo!
          ; )

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

          kind regards,

          Jos ;-)

          Comment

          • prometheuzz
            Recognized Expert New Member
            • Apr 2007
            • 197

            #6
            Originally posted by JosAH
            I agree; that guy is a nutcase.

            kind regards,

            Jos ;-)
            Oh, no doubt about it!
            ; )

            Comment

            • JosAH
              Recognized Expert MVP
              • Mar 2007
              • 11453

              #7
              Originally posted by prometheuzz
              Oh, no doubt about it!
              ; )
              Ok, so we both agree on that; case closed; *grmph*

              kind regards,

              Jos ;-)

              Comment

              • prometheuzz
                Recognized Expert New Member
                • Apr 2007
                • 197

                #8
                Originally posted by JosAH
                Ok, so we both agree on that; case closed; *grmph*

                kind regards,

                Jos ;-)
                My mother always warned me not to disagree with mathematicians!
                ; )

                Comment

                • r035198x
                  MVP
                  • Sep 2006
                  • 13225

                  #9
                  I disagree of course.
                  Everything is binary.

                  Comment

                  • praveen2gupta
                    New Member
                    • May 2007
                    • 200

                    #10
                    Originally posted by mahi543
                    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.

                    Comment

                    • JosAH
                      Recognized Expert MVP
                      • Mar 2007
                      • 11453

                      #11
                      Originally posted by praveen2gupta
                      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

                      Comment

                      Working...