Forum Discussion
May 23, 2006
I'd be careful about dropping the high 32 bits of those values. For memory it's probably OK as long as you don't have more than 4GB. A safer approach would be to build a native 64 bit value from the low and high components of our UInt64 structure.
my $total_memory = &build64($memory_info->{"total_memory"});
----------------------------------------------------------------------------
build64
----------------------------------------------------------------------------
sub build64()
{
($UInt64) = (@_);
$low = $UInt64->{"low"};
$high = $UInt64->{"high"};
For some reason this doesn't work...
$value64 = Math::BigInt->new($high)->blsft(32)->bxor($low);
$value64 = Math::BigInt->new(Math::BigInt->new($high)->blsft(32))->bxor($low);
return $value64;
}
I guess that's assuming you don't have 64bit support builtin (which isn't the default) and you have the Math::BigInt module on your system.
-Joe