Lab-Measurement-Legacy
view release on metacpan or search on metacpan
lib/Lab/Data/Analysis/WaveRunner.pm view on Meta::CPAN
my $f = $str & 0x007FFFFF;
my $w = ( 2**( $e - 127 ) ) * ( 1 + ( $f / 0x00800000 ) );
$w = -$w if $s;
return $w;
}
sub double_from_hex { unpack 'd', scalar reverse pack 'H*', $_[0] }
use constant POS_INF => double_from_hex '7FF0000000000000';
use constant NEG_INF => double_from_hex 'FFF0000000000000';
use constant NaN => double_from_hex '7FF8000000000000';
sub _double # assumes MSB data input
{
# my ($bytes) = @_;
# my ($bottom, $top) = unpack ("LL", $bytes);
my ( $top, $bottom ) = @_;
# Reference:
# http://en.wikipedia.org/wiki/Double_precision_floating-point_format
lib/Lab/Data/Analysis/WaveRunner.pm view on Meta::CPAN
return -0;
}
elsif ( $top == 0x7ff00000 ) {
return POS_INF;
}
elsif ( $top == 0xfff00000 ) {
return NEG_INF;
}
}
elsif ( $top == 0x7ff00000 ) {
return NaN;
}
my $sign = $top >> 31;
# print "sgn $sign\n";
my $exponent = ( ( $top >> 20 ) & 0x7FF ) - 1023;
# print "e = $exponent\n";
my $e = ( $top >> 20 ) & 0x7FF;
my $t = $top & 0xFFFFF;
( run in 0.408 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )