From: Stefan Schmiedl Date: 2001-12-02T20:47:15+09:00 Subject: [ruby-talk:27267] Re: Any build-in method for decimal to hexadecimal conversion? E Chelon (2001-12-02 17:59): > Hi, > > I'd like to know if there is any build-in method for > convering a decimal value to hexadecimal, please? > > i.e. the reverse of "0xE".hex => 10 > > Currently, as an ad hoc solution, I use sprintf("%X", value) > which is not that ruby ... > irb irb(main):001:0> class Integer irb(main):002:1> def hex irb(main):003:2> sprintf "%x", self irb(main):004:2> end irb(main):005:1> end nil irb(main):006:0> 159.hex "9f" That's "enough Ruby" I guess :-) just add your method to the built-in Integer class. s. > Thanks. > > e_chelon how's your pet doing? still eating meat? :-) -- Stefan Schmiedl EDV-Beratung, Programmierung, Schulung Loreleystr. 5, 94315 Straubing, Germany Tel. (0 94 21) 74 01 06 Public Key: http://xss.de/stefan.public shhhh ... I can't hear my code!