in reply to Re^2: Equivalent of unpack 'q' with 32-bit Perl (a8)
in thread Equivalent of unpack 'q' with 32-bit Perl
No, I mean dont do any conversion if its not possible :) treat it as a string, convert as quad when you can, otherwise its raw bytes ...
There is always bigint which says
print hex("0x1234567890123490"),"\n"; # Perl v5.10.0 or later
So
use constant CAN_PACK_QUADS => !! eval { my $f = pack 'q'; 1 }; use Math::BigInt; print quad('ffffffffffff'), "\n"; sub quad { CAN_PACK_QUADS ? unpack( 'q<', $_[0] ) : Math::BigInt->new( '0x'.$_[0] ) } __END__
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Equivalent of unpack 'q' with 32-bit Perl (a8)
by Limbic~Region (Chancellor) on Sep 06, 2016 at 23:01 UTC | |
by Anonymous Monk on Sep 06, 2016 at 23:41 UTC | |
by Limbic~Region (Chancellor) on Sep 06, 2016 at 23:51 UTC | |
by RonW (Parson) on Sep 07, 2016 at 20:41 UTC | |
by Limbic~Region (Chancellor) on Sep 07, 2016 at 20:54 UTC | |
| |
by Anonymous Monk on Sep 07, 2016 at 22:14 UTC |