Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add two hexadeximal number

Status
Not open for further replies.

csudess

Technical User
Apr 1, 2010
14
HU
How could i add two hexadecimal number? thank u for ur answer
 
so then!
i would like to do this

$numb1="\x64";
$numb2="\x01";

$value=$numb1+$numb2;
print "$value"; #
it would be really good if the $value would eg \x65!

but its not!:(
 
\x64 means the character represented by 64 hexadecimal in the current character set (usually a lower case 'd'). You can use the syntax 0x64 for hexadecimal constants in perl.

Do add and print hexadecimal numbers you need to use something like:

Code:
$numb1=0x64;
$numb2=0x01;
$value=$numb1+$numb2;
printf "0x%x\n",$value;

The %x means to insert the value of $value into the format string in hexadecimal format. See perldoc -f printf and especially perldoc -f sprintf for details about output formats.

Annihilannic.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top