Add support for bitwise not

Issue #382 new
Former user created an issue

Originally reported on Google Code with ID 382

There are bitwise AND, OR and Shift operators in the latest code, but no bitwise not.

The not function seems to be doing a 2's complement, not a straight toggle of bits.

E.g. not(0b101010) = -0b101011 (I am expecting 0b010101)

Can you please a ~ operator that simply toggles the bits, (like the C++ ~ operator)?

Thanks
Alan.

Reported by alan.n.davies on 2011-07-05 13:44:25

Comments (8)

  1. Former user Account Deleted
    Hi, Alan. SpeedCrunch's not(x) function yields the exact same results as the C/C++ ~
    unary operator, i.e. (~x) == (-x-1).
    

    Reported by helder.pereira.correia on 2012-11-05 08:34:24

  2. Former user Account Deleted
    Except the binary representation of -43 (-x-1, where x==42) in c++ is different to the
    binary representation of -43 in Speed Crunch.
    
    ~42 in c++ results in 0b11111111111111111111111111010101 (pure bitwise not).
    not(42) in Speed Crunch gives -0b101011 (adds one to the number and puts a negative
    sign in front).
    

    Reported by alan.n.davies on 2012-11-05 11:40:54

  3. Former user Account Deleted

    So is there going to be a solution for this in the near future? or are there a temporary fix for us lazy ass's who do not want to do a bitwise not ourselves

  4. Log in to comment