From: "akr (Akira Tanaka)" Date: 2013-07-28T00:34:37+09:00 Subject: [ruby-core:56232] [ruby-trunk - Bug #8697][Feedback] Fixnum complement operator issue Issue #8697 has been updated by akr (Akira Tanaka). Status changed from Open to Feedback Please show us an actual problem. At least, ~0 is -1 as follows. % ./ruby -v -e 'p ~0' ruby 2.1.0dev (2013-07-26 trunk 42199) [x86_64-linux] -1 -1 is the number which all bits are one. 0 is the number which all bits are zero. So, -1 is the one's complement of 0 as documented. ---------------------------------------- Bug #8697: Fixnum complement operator issue https://bugs.ruby-lang.org/issues/8697#change-40720 Author: torimus (Torimus GL) Status: Feedback Priority: Normal Assignee: Category: core Target version: current: 2.1.0 ruby -v: 1.9.3p448 Backport: 1.9.3: UNKNOWN, 2.0.0: UNKNOWN =begin By the (()), bitwise complement operator ((*~*)) to Fixnum instance should do ((*one's complement*)) with just flipping all bits. In fact, current implementation does ((*two's complement*)) due to or-ing with FIXNUM_FLAG, which is defined as 1. Either fix the documentation or the fix_rev function implementation. Affected versions: both 1.9.3 and 2.0.0 =end -- http://bugs.ruby-lang.org/