Issue #8697 has been updated by torimus (Torimus GL).


=begin
When one's completion is applied to zero, the result is ((*not*)) -1 but so called "negative zero", ie. -0.
What you are talking about is two's completion, ie. "the value of 1 is then added to the resulting value of bitwise not operation".

It's all about improper use of terminology.

See related articles on Wikipedia: ((<One's complement|URL:http://en.wikipedia.org/wiki/Ones%27_complement>)) and ((<Two's complement|URL:http://en.wikipedia.org/wiki/Two%27s_complement>)) .
=end

----------------------------------------
Bug #8697: Fixnum complement operator issue
https://bugs.ruby-lang.org/issues/8697#change-40724

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 ((<documentation|URL:http://www.ruby-doc.org/core-2.0/Fixnum.html#method-i-7E>)), 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/