+ Reply to Thread
Results 1 to 3 of 3

Binary Complement

  1. #1
    RK
    Guest

    Binary Complement

    How can I complement binary numbers so that 0 becomes 1 and 1 becomes
    0. Also, is there a way to reverse the order of binary digits (i.e.
    write backward)?


  2. #2
    JE McGimpsey
    Guest

    Re: Binary Complement

    One way:

    Assuming your binary numbers are less than or equal to 10 binary digits,
    and you have the Analysis Toolpak Add-in installed (Tools/Add-ins...):

    =RIGHT(DEC2BIN(-BIN2DEC(A1)-1),LEN(A1))


    In article <1124314805.887026.131450@f14g2000cwb.googlegroups.com>,
    "RK" <rskim119@yahoo.com> wrote:

    > How can I complement binary numbers so that 0 becomes 1 and 1 becomes
    > 0.


  3. #3
    Harlan Grove
    Guest

    Re: Binary Complement

    RK wrote...
    >How can I complement binary numbers so that 0 becomes 1 and 1 becomes
    >0. Also, is there a way to reverse the order of binary digits (i.e.
    >write backward)?


    First question:

    =TEXT(SUMPRODUCT(1-MID(x,ROW(INDIRECT("1:"&LEN(x))),1),
    10^(LEN(x)-ROW(INDIRECT("1:"&LEN(x))))),REPT("0",LEN(x)))

    Second question:

    =TEXT(SUMPRODUCT(--MID(x,ROW(INDIRECT("1:"&LEN(x))),1),
    10^(ROW(INDIRECT("1:"&LEN(x)))-1)),REPT("0",LEN(x)))

    This only works for 15 or fewer binary digits. You'd have to chop up
    longer binary numbers into 8-byte portions, apply these formulas to the
    pieces, then concatenate their results to give the desired results.


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1