Re: How to convert from string to hex number
- From: noreply@xxxxxxxxx (Gunnar Hjalmarsson)
- Date: Fri, 17 Aug 2007 12:48:54 +0200
dinesh wrote:
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 think it must be a string, or else Perl will convert it to decimal whether you like it or not...
my $num = 0x82;
print "$num\n"; # prints 130
So if the function expects a hex value, you'd better pass it as a string.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
.
- Follow-Ups:
- Re: How to convert from string to hex number
- From: Nobull67@xxxxxxxxx
- Re: How to convert from string to hex number
- References:
- How to convert from string to hex number
- From: Dinesh
- How to convert from string to hex number
- Prev by Date: Re: File::Find help
- Next by Date: Re: Serial port programming in perl
- Previous by thread: How to convert from string to hex number
- Next by thread: Re: How to convert from string to hex number
- Index(es):
Relevant Pages
|