Forum: Ruby 10.to_hex?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
uval (Guest)
on 2005-11-19 04:35
(Received via mailing list)
Hello,

I can't find the function to convert an number to its hex representation
I feel it must be there ..

irb(main):068:0> Integer.methods.grep /hex/
=> []
irb(main):069:0> Numeric.methods.grep /hex/
=> []

Regards, Daniel
marcel (Guest)
on 2005-11-19 04:38
(Received via mailing list)
On Sat, Nov 19, 2005 at 11:32:25AM +0900, Daniel Sch?le wrote:
> Hello,
>
> I can't find the function to convert an number to its hex representation
> I feel it must be there ..
>
> irb(main):068:0> Integer.methods.grep /hex/
> => []
> irb(main):069:0> Numeric.methods.grep /hex/
> => []

ri sprintf

Search for 'hex'.

(x and X)

marcel
tobias.luetke (Guest)
on 2005-11-19 04:44
(Received via mailing list)
10.to_s(16) #=> a

class Numeric
   def to_hex
      to_s(16)
   end
end

10.to_hex #=> a

On 11/18/05, Daniel Schüle <removed_email_address@domain.invalid> wrote:
> Regards, Daniel
>
>
>


--
Tobi
http://jadedpixel.com    - modern e-commerce software
http://typo.leetsoft.com - Open source weblog engine
http://blog.leetsoft.com - Technical weblog
This topic is locked and can not be replied to.