String#pack?

I was wondering if there was a method in ruby to obtain the hexadecimal
representation of numbers (ie. fixnum, floats, mainly) in either msb or in lsb
order.
Basically, I'm kind of looking for the opposite function of String#unpack().

I'm not 100% sure I understood the question, but does this do what you're after?

% ruby -e 'puts "%x" % 123'
7b

Hope that helps.

James Edward Gray II

ยทยทยท

On Oct 1, 2004, at 5:14 PM, GGarramuno wrote:

I was wondering if there was a method in ruby to obtain the hexadecimal
representation of numbers (ie. fixnum, floats, mainly) in either msb or in lsb
order.
Basically, I'm kind of looking for the opposite function of String#unpack().

GGarramuno wrote:

Basically, I'm kind of looking for the opposite function of String#unpack().

It's Array#pack.

Regards,
Florian Gross

"Florian Gross" <flgr@ccan.de> schrieb im Newsbeitrag news:2s682mF1haft1U1@uni-berlin.de...

GGarramuno wrote:

Basically, I'm kind of looking for the opposite function of String#unpack().

It's Array#pack.

Also there is to_s(radix):

128.to_s(16)

=> "80"

Kind regards

    robert