line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package oEdtk::SignedField;
|
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Decode a signed amount field encoded using Infinite conventions.
|
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
796
|
use strict;
|
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
47
|
|
6
|
1
|
|
|
1
|
|
7
|
use warnings;
|
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
37
|
|
7
|
|
|
|
|
|
|
|
8
|
1
|
|
|
1
|
|
6
|
use base 'oEdtk::Field';
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
572
|
|
9
|
|
|
|
|
|
|
our $VERSION = 0.01;
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
sub new {
|
12
|
0
|
|
|
0
|
0
|
|
my ($class, $name, $ilen, $flen) = @_;
|
13
|
|
|
|
|
|
|
|
14
|
0
|
0
|
|
|
|
|
$flen = 0 unless defined($flen);
|
15
|
0
|
|
|
|
|
|
my $self = $class->SUPER::new($name, $ilen + $flen);
|
16
|
0
|
|
|
|
|
|
$self->{'intlen'} = $ilen;
|
17
|
0
|
|
|
|
|
|
$self->{'fraclen'} = $flen;
|
18
|
0
|
|
|
|
|
|
return $self;
|
19
|
|
|
|
|
|
|
}
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub process {
|
22
|
0
|
|
|
0
|
0
|
|
my ($self, $data) = @_;
|
23
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
|
$data =~ s/\s+//g;
|
25
|
|
|
|
|
|
|
|
26
|
0
|
0
|
|
|
|
|
if ($data !~ /^-?\d*[p-y]?$/) {
|
27
|
0
|
|
|
|
|
|
warn "INFO : Unexpected numerical value: $data in ".$self->{'name'}."\n";
|
28
|
|
|
|
|
|
|
}
|
29
|
|
|
|
|
|
|
|
30
|
0
|
0
|
|
|
|
|
if ($data eq '') {
|
31
|
0
|
|
|
|
|
|
$data = 0;
|
32
|
|
|
|
|
|
|
}
|
33
|
0
|
0
|
|
|
|
|
if ($data =~ s/([p-y])$/ord($1) - ord('p')/e) {
|
|
0
|
|
|
|
|
|
|
34
|
0
|
|
|
|
|
|
$data *= -1;
|
35
|
|
|
|
|
|
|
}
|
36
|
|
|
|
|
|
|
|
37
|
0
|
|
|
|
|
|
my $flen = $self->{'fraclen'};
|
38
|
0
|
0
|
0
|
|
|
|
if ($data !~ /\./ && $flen > 0) {
|
39
|
0
|
|
|
|
|
|
$data /= 10 ** $flen;
|
40
|
0
|
|
|
|
|
|
return sprintf("%.${flen}f", $data);
|
41
|
|
|
|
|
|
|
}
|
42
|
0
|
|
|
|
|
|
return $data;
|
43
|
|
|
|
|
|
|
}
|
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
1;
|