I looked at the 'D' format, and it would work on machines that have 64bit integer hardware, but I need to support some 32 bit only machines. But you got me thinking, and I used some basic math to get what I need (I hope?).
The following code seems to do what I need:
I profiled the code and 'pack/unpack' sequence is about 2us/call. The 'Pack' is about 16us per call and the 'UnPack' is about 14us per call. Expensive, but I would then get network neutral code to 562TB, and that would be good.use strict; use warnings; my $num4g = 2 ** 32; my $grt4g = 500_000 + $num4g ; my $start = $num4g - 50; my $no = 0; while ( 1 ) { my $no1 = Pack( $start ); my $result = UnPack( "$no1" ); if ( $start != $result ) { die "not match"; } $start++; $no++; if ( $start >= $grt4g ) { print "Okay ( $no )\n"; exit; } } sub Pack { my $input = shift; my $lower = $input % $num4g; my $upper = int ( $input / $num4g ); return ( pack("N N", $upper, $lower ) ); } sub UnPack { my $input = shift; my ( $upper, $lower ) = unpack("N N", $input); return ( ( $upper * $num4g ) + $lower ); } 1;
Do you see anything wrong with the code?
Thank you
"Well done is better than well said." - Benjamin Franklin
In reply to Re^6: Will Perl Scripts written on 64 Bit Windows run fine on 32 bit as well?
by flexvault
in thread Will Perl Scripts written on 64 Bit Windows run fine on 32 bit as well?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |