From: Tammo Freese Date: 2001-03-14T01:27:28+09:00 Subject: [ruby-talk:12572] bug in String#hex and String#oct Hello, by scanning through the reference in the pickaxe book and trying out things with IRB, I have found a strange behaviour. The method String#hex is described: "Treats leading characters [...] as a string of hexadecimal digits (with an optional sign and an optional 0x) and returns the corresponding number. Zero is returned on error." So I expected zero when calling this method on a string that begins with two signs. However, here are the results: $ ruby -ve 'puts "++1".hex.to_s' ruby 1.6.3 (2001-03-07) [i686-cygwin] 1 $ ruby -ve 'puts "+-1".hex.to_s' ruby 1.6.3 (2001-03-07) [i686-cygwin] 4294967295 $ ruby -ve 'puts "-+1".hex.to_s' ruby 1.6.3 (2001-03-07) [i686-cygwin] -1 $ ruby -ve 'puts "--1".hex.to_s' ruby 1.6.3 (2001-03-07) [i686-cygwin] -4294967295 With three signs, zero is returned. String#oct has the same behaviour. - Tammo Freese freese@acm.org