Hex to decimals

Any suggestions on how to convert a Hex value to its decimal equivalent?
Have been coming up blank on this one. Thanks,

-S

Shandy N. wrote:

Any suggestions on how to convert a Hex value to its decimal equivalent?
Have been coming up blank on this one. Thanks,

-S

‘0xf’.hex
=> 15

Ilan B. wrote:

Shandy N. wrote:

Any suggestions on how to convert a Hex value to its decimal equivalent?
Have been coming up blank on this one. Thanks,

-S

‘0xf’.hex
=> 15

what about a base64 to a decimal? I have seen some examples using pack
and unpack but I’m not sure what they do? Thanks,

-S

Shandy N. wrote:

Any suggestions on how to convert a Hex value to its decimal equivalent?
Have been coming up blank on this one. Thanks,

-S

This is what it is for base 16:

p 10.to_s(16)
=> ‘a’
p ‘a’.to_i(16)
=>10

Just use the base you want in the parens.

On 10.12.2007 19:09, Shandy N. wrote:

Any suggestions on how to convert a Hex value to its decimal equivalent?
Have been coming up blank on this one. Thanks,

$ ruby -e ‘puts “deaf”.to_i(16)’
57007

:wink:

robert

From: “Shandy N.” [email protected]

Any suggestions on how to convert a Hex value to its decimal equivalent?
Have been coming up blank on this one. Thanks,

“ff”.to_i(16)
=> 255

Regards,

Bill