How can I do 64-bit arithmetic in Perl?

Alphaneo picture Alphaneo · Dec 8, 2009 · Viewed 11.5k times · Source

I am a perl newbie,

Can I simply use 64-bit arithmetic in Perl?

For example

$operand1 = 0xFFFFFFFFFFFF;   # 48 bit value
$operand2 = 0xFFFFFFFFFFFF;   # 48 bit value

$Result = $operand1 * $operand2;
  • I am basically looking for a replacement for the int64_t in perl.
  • Is there any way to mention, if the variable is signed or unsigned?

Answer

Alan Haggai Alavi picture Alan Haggai Alavi · Dec 8, 2009

Yes, however you need to have Perl compiled with 64-bit support.