line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Number Object Role for Perl 5 |
2
|
|
|
|
|
|
|
package Data::Object::Role::Number; |
3
|
|
|
|
|
|
|
|
4
|
145
|
|
|
145
|
|
460246
|
use 5.010; |
|
145
|
|
|
|
|
499
|
|
5
|
145
|
|
|
145
|
|
20907
|
use Data::Object::Role; |
|
145
|
|
|
|
|
311
|
|
|
145
|
|
|
|
|
1185
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
map with($_), our @ROLES = qw( |
8
|
|
|
|
|
|
|
Data::Object::Role::Defined |
9
|
|
|
|
|
|
|
Data::Object::Role::Detract |
10
|
|
|
|
|
|
|
Data::Object::Role::Numeric |
11
|
|
|
|
|
|
|
Data::Object::Role::Output |
12
|
|
|
|
|
|
|
Data::Object::Role::Type |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.42'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub abs { |
18
|
1
|
|
|
1
|
0
|
2
|
my ($number) = @_; |
19
|
1
|
|
|
|
|
49
|
return CORE::abs $number; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub atan2 { |
23
|
1
|
|
|
1
|
0
|
2
|
my ($number, $x) = @_; |
24
|
1
|
|
|
|
|
47
|
return CORE::atan2 $number, $x; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
sub cos { |
28
|
1
|
|
|
1
|
0
|
2
|
my ($number) = @_; |
29
|
1
|
|
|
|
|
55
|
return CORE::cos $number; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub decr { |
33
|
1
|
|
|
1
|
0
|
1
|
my ($number, $n) = @_; |
34
|
1
|
|
50
|
|
|
51
|
return $number - ($n || 1); |
35
|
|
|
|
|
|
|
} |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub exp { |
38
|
1
|
|
|
1
|
0
|
3
|
my ($number) = @_; |
39
|
1
|
|
|
|
|
49
|
return CORE::exp $number; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub hex { |
43
|
1
|
|
|
1
|
0
|
2
|
my ($number) = @_; |
44
|
1
|
|
|
|
|
55
|
return sprintf '%#x', $number; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub incr { |
48
|
1
|
|
|
1
|
0
|
2
|
my ($number, $n) = @_; |
49
|
1
|
|
50
|
|
|
67
|
return $number + ($n || 1); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub int { |
53
|
1
|
|
|
1
|
0
|
2
|
my ($number) = @_; |
54
|
1
|
|
|
|
|
53
|
return CORE::int $number; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub log { |
58
|
1
|
|
|
1
|
0
|
3
|
my ($number) = @_; |
59
|
1
|
|
|
|
|
49
|
return CORE::log $number; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub mod { |
63
|
5
|
|
|
5
|
0
|
7
|
my ($number, $divisor) = @_; |
64
|
5
|
|
|
|
|
72
|
return $number % $divisor; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub neg { |
68
|
1
|
|
|
1
|
0
|
2
|
my ($number) = @_; |
69
|
1
|
|
|
|
|
49
|
return -$number; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
sub pow { |
73
|
1
|
|
|
1
|
0
|
3
|
my ($number, $n) = @_; |
74
|
1
|
|
|
|
|
51
|
return $number ** $n; |
75
|
|
|
|
|
|
|
} |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub sin { |
78
|
1
|
|
|
1
|
0
|
2
|
my ($number) = @_; |
79
|
1
|
|
|
|
|
54
|
return CORE::sin $number; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub sqrt { |
83
|
1
|
|
|
1
|
0
|
2
|
my ($number) = @_; |
84
|
1
|
|
|
|
|
50
|
return CORE::sqrt $number; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
__END__ |