On Wed, Mar 20, 2002 at 06:40:54AM +0900, Phil Tomson wrote: > We've got: > String#hex > String#oct > > but there is no String#bin. > > It seems that we should have a String#bin for completeness. IMO, String#oct is evil. Consider: "0xff".oct #=> 255 (this is a hex number, not octal) "0bff".oct #=> 0 (this is an invalid binary number) "0b77".oct #=> 0 (this is also an invalid binary number) "0b11".oct #=> 3 (this is a valid binary number) "b11".oct #=> 0 (this is an invalid octal number) "11".oct #=> 9 (this is a valid octal number) Additionally, both String#oct and String#hex return 0 on error, which means I have no way to distinguish between an error condition and the number zero. A preferable solution would be a Ruby interface to rb_str2inum. This is still not optimal, because there is still (afaict) no way to detect bad data. A Ruby interface to strtoul would work, but would not work with Bignums. Paul