Add ~ as bitwise complement operator

Issue #838 new
Former user created an issue

While trying to calculate the 32-bit boundary of an image I discovered that speedcruch doesn't handle this type of math. I'm not sure if it's a bug or if it was never intended to do this.

((2550 * 8 + 31) & ~31)/8 = 1.875 //Should Be 2552

((2550 * 24 + 31) & ~31)/8 = 1.875 //Should Be 7652

((2550 * 32 + 31) & ~31)/8 = 3.875 //Should Be 10200

Comments (5)

  1. fdncred

    I should've said complement vs compliment when I created this issue. LOL. I figure this problem is due to have 2 operators & and ~ next to each other but I haven't looked at the code to understand how the parsing works. Thanks for the awesome calculator.

  2. Tey'

    Thanks for your report. The complement operator is not, the ~ operator does not exist and is ignored.

    #!
    
    ((2550 * 8 + 31) & not 31)/8
    = 2552
    
    ((2550 * 24 + 31) & not 31)/8
    = 7652
    
    ((2550 * 32 + 31) & not 31)/8
    = 10200
    

    If you find it strange that the ~ character does not trigger any error, check #821.

    Maybe we should consider aliasing ~ to not, especially since ~ appears on the bitfield widget. @heldercorreia What do you think about it?

  3. fdncred

    Thanks for the clarification. I saw not but wasn't sure how to use it and I wasn't sure if Logical NOT meant the same as Bitwise NOT. Adding ~ would clear it up though.

  4. Log in to comment