Results 1 to 4 of 4

Two's Complement

Threaded View

  1. #1
    Registered User
    Join Date
    02-13-2014
    Location
    Somewhere, Rainbow
    MS-Off Ver
    Excel 2007
    Posts
    20

    Two's Complement

    All,

    I am attempting to convert both positive (127) and negative numbers (like -128) from Decimal (signed integer 8-bit) to Binary to Hexadecimal (1 byte). When it comes to positive numbers, that's pretty simple. However, when dealing with negative numbers, I am unsure how to implement the "Two's Complement" in Excel.

    Here's what I have so far

    Input Cell (K2)
    Output Cell (L2)

    Cell N2=IF(K2<0,MID(K2,2,3),K2)
    Cell O2=DEC2BIN(N2)

    Cell Q2=BIN2HEX(O2,2)


    So if I input 127, Cell O2 reads 1111111. When I input -128, Cell O2 read 10000000. When using the "Two's Complement" rule, I would reverse 10000000 then add 1, it should then read 110000000.

    However, I have no idea how to reverse the binary and add a binary 1 to the result. My initial thought would be to parse out the binary, manually reverse the numbers (=IF(X2>0,0,IF(X2<1,1)). If that's the way I have to do this reversal, there still lies the question of how to add a binary 1 to the results.

    As always, thank you for reading and any input is appreciated!

    Respectfully,
    Talamon
    Last edited by Talamon; 02-20-2014 at 01:06 PM.

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Macro or function available for making reverse complement DNA sequence ?
    By matthijskol in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 01-03-2013, 11:51 AM
  2. [SOLVED] Complement of Two Arrays
    By pratyu in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2012, 07:07 AM
  3. [SOLVED] Binary Complement
    By RK in forum Excel General
    Replies: 2
    Last Post: 08-17-2005, 07:05 PM
  4. How do I solve for complement rule of P(X &amp;gt; or = 4.0) in excel?
    By OKONITA in forum Excel - New Users/Basics
    Replies: 1
    Last Post: 06-15-2005, 07:05 AM
  5. A function of reverse complement
    By M H in forum Excel Programming / VBA / Macros
    Replies: 21
    Last Post: 01-19-2005, 10:06 AM

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