How to convert from string to hex number



Hello,

I have a requirement for passing a hex value like this to a function.

Example code:
my $ipmbAddress = getIpmbAddress(...); ## returns 82

getDeviceID($ip, $ipmbAddress);

Here in the above code, the getDeviceID() fucntion will accept only
0x82 (hex number). How to convert the number 82 to 0x82 (Note that
this should not be as string)

I tried the following but not working properly.
$ipmbAddress = "0x".$ipmbAddress;
$ipmbAddress = hex("$ipmbAddress");
$ipmbAddress = sprintf(0x%0x, $ipmbAddress);
getDeviceID($ip, $ipmbAddress);


Please help.

Thanks,
DineshK
===========

.



Relevant Pages

  • RE: [PHP] ImageColorAllocate() Problem
    ... I think it might be because you're passing a string to the function instead ... of a hex value... ... $color starts off as a hex color code minus the #, ... is pulled into each of the 3 alpha values by way for the hex variables. ...
    (php.general)
  • Decimal to Hex in g++
    ... How do i convert a Decimal number to Hex in g++, ... an itoa function so what is the best way to do this? ... int number = 30; ... I will be passing this number to another program which will change the ...
    (comp.unix.programmer)