ANDing and ORing question...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • MLH

    ANDing and ORing question...

    If I have an integer A and I logically AND it
    with some other integer B to produce a result
    C, can I then perform some kind of reverse
    operation with B and C to get back the original
    number A?

    If so, is it guaranteed to work every time with
    all integers A and B?
  • Bas Cost Budde

    #2
    Re: ANDing and ORing question...

    No!
    With AND, you may set one or more bits in A to zero. That information is
    then lost.

    MLH wrote:
    [color=blue]
    > If I have an integer A and I logically AND it
    > with some other integer B to produce a result
    > C, can I then perform some kind of reverse
    > operation with B and C to get back the original
    > number A?
    >
    > If so, is it guaranteed to work every time with
    > all integers A and B?[/color]

    --
    Bas Cost Budde, Holland

    For human replies, replace the queue with a tea

    Comment

    • Tom van Stiphout

      #3
      Re: ANDing and ORing question...

      On Sat, 02 Jul 2005 14:13:10 -0400, MLH <CRCI@NorthStat e.net> wrote:

      That's why we have XOR:

      Sub x2()
      Dim A As Integer
      Dim B As Integer

      A = 10 ' or any other number
      B = 20 ' or any other number
      A = A Xor B
      A = A Xor B
      Debug.Print A

      End Sub


      [color=blue]
      >If I have an integer A and I logically AND it
      >with some other integer B to produce a result
      >C, can I then perform some kind of reverse
      >operation with B and C to get back the original
      >number A?
      >
      >If so, is it guaranteed to work every time with
      >all integers A and B?[/color]

      Comment

      • Mike MacSween

        #4
        Re: ANDing and ORing question...

        "MLH" <CRCI@NorthStat e.net> wrote in message
        news:04mdc1d0dq hem1hmqtf95t0kr b5durmmpm@4ax.c om...[color=blue]
        > If I have an integer A and I logically AND it
        > with some other integer B to produce a result
        > C, can I then perform some kind of reverse
        > operation with B and C to get back the original
        > number A?[/color]

        Wwwwwhhhhhhhhhh aaaaaaaaaaaaaat ttttttttttttttt ?


        Comment

        • Mike MacSween

          #5
          Re: ANDing and ORing question...

          Oh I see

          "Bas Cost Budde" <b.costbudde@he uvelqop.nl> wrote in message
          news:da6sdo$ii6 $6@localhost.lo caldomain...[color=blue]
          > No!
          > With AND, you may set one or more bits in A to zero. That information is
          > then lost.
          >
          > MLH wrote:
          >[color=green]
          >> If I have an integer A and I logically AND it
          >> with some other integer B to produce a result
          >> C, can I then perform some kind of reverse
          >> operation with B and C to get back the original
          >> number A?
          >>
          >> If so, is it guaranteed to work every time with
          >> all integers A and B?[/color]
          >
          > --
          > Bas Cost Budde, Holland
          > http://www.heuveltop.nl/BasCB/msac_index.html
          > For human replies, replace the queue with a tea
          >[/color]


          Comment

          Working...