From: Ian Roddis Date: 2006-10-24T22:49:24+09:00 Subject: Bitwise inversion of Bignum A bitwise inversion of a Bignum sometimes yields odd results. As tested in 1.8.5: ./ruby -v ruby 1.8.5 (2006-08-25) [i686-linux] ./ruby -e 'a= "7fffff00".hex ; b= "ffffff00".hex ; printf "%b => %b\n", a, ~a ; printf "%b => %b\n", b, ~b' 1111111111111111111111100000000 => ..10000000000000000000000011111111 11111111111111111111111100000000 => ..1 In the first case, the '..1' is expected, as per the documentation, but annoying. Generally when I need to invert a number, I expect a result of the same length as the original. Since ruby number classes are inherently variable length I could not rely on the non-significant bits even if I wanted to. Is it possible to put in a vote for a Bignum ~ operation to return a value of the same length as the largest argument? The second case is just bizzare. Is this a bug? -- Posted via http://www.ruby-forum.com/.