Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl long data type

I am writing an app in Perl that requires long data type instead of integers. How can I achieve this. For example;

my $num = sprintf('%ld', 27823221234);

print $num;

The output is not a long, but an integer.

like image 303
Gruther Avatar asked Jan 27 '26 01:01

Gruther


1 Answers

Your options are:

  • use a perl compiled for 64 bits
  • use Math::Int64
  • use Math::BigInt

update: ah, you can also use floats instead of integers:

printf("%.0f", 2**50)

IIRC, on most current architectures, floats can represent integers up to 2**54-1 precisely.

like image 173
salva Avatar answered Jan 28 '26 19:01

salva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!