line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Common Methods for Operating on Numbers |
2
|
|
|
|
|
|
|
package Bubblegum::Object::Number; |
3
|
|
|
|
|
|
|
|
4
|
36
|
|
|
36
|
|
20010
|
use 5.10.0; |
|
36
|
|
|
|
|
108
|
|
|
36
|
|
|
|
|
1539
|
|
5
|
36
|
|
|
36
|
|
189
|
use namespace::autoclean; |
|
36
|
|
|
|
|
48
|
|
|
36
|
|
|
|
|
199
|
|
6
|
|
|
|
|
|
|
|
7
|
36
|
|
|
36
|
|
2085
|
use Bubblegum::Class 'with'; |
|
36
|
|
|
|
|
56
|
|
|
36
|
|
|
|
|
235
|
|
8
|
36
|
|
|
36
|
|
27315
|
use Bubblegum::Constraints -isas, -types; |
|
36
|
|
|
|
|
63
|
|
|
36
|
|
|
|
|
413
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with 'Bubblegum::Object::Role::Coercive'; |
11
|
|
|
|
|
|
|
with 'Bubblegum::Object::Role::Value'; |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our @ISA = (); # non-object |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
our $VERSION = '0.45'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
sub abs { |
18
|
2
|
|
|
2
|
1
|
2911
|
my $self = CORE::shift; |
19
|
2
|
|
|
|
|
9
|
return CORE::abs $self; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub atan2 { |
23
|
1
|
|
|
1
|
1
|
2993
|
my $self = CORE::shift; |
24
|
1
|
|
|
|
|
6
|
my $x = type_number CORE::shift; |
25
|
1
|
|
|
|
|
424
|
return CORE::atan2 $self, $x; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub cos { |
29
|
1
|
|
|
1
|
1
|
3064
|
my $self = CORE::shift; |
30
|
1
|
|
|
|
|
20
|
return CORE::cos $self; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub decr { |
34
|
1
|
|
|
1
|
1
|
3022
|
my $self = CORE::shift; |
35
|
1
|
50
|
|
|
|
4
|
my $n = type_number CORE::shift if $_[0]; |
36
|
1
|
|
50
|
|
|
7
|
return $self - ($n || 1); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub exp { |
40
|
3
|
|
|
3
|
1
|
3081
|
my $self = CORE::shift; |
41
|
3
|
|
|
|
|
21
|
return CORE::exp $self; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub hex { |
45
|
1
|
|
|
1
|
1
|
3032
|
my $self = CORE::shift; |
46
|
1
|
|
|
|
|
7
|
return CORE::sprintf '%#x', $self; |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub incr { |
50
|
1
|
|
|
1
|
1
|
3025
|
my $self = CORE::shift; |
51
|
1
|
50
|
|
|
|
4
|
my $n = type_number CORE::shift if $_[0]; |
52
|
1
|
|
50
|
|
|
8
|
return $self + ($n || 1); |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub int { |
56
|
1
|
|
|
1
|
1
|
3417
|
my $self = CORE::shift; |
57
|
1
|
|
|
|
|
5
|
return CORE::int $self; |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
sub log { |
61
|
1
|
|
|
1
|
1
|
3158
|
my $self = CORE::shift; |
62
|
1
|
|
|
|
|
13
|
return CORE::log $self; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
sub mod { |
66
|
5
|
|
|
5
|
1
|
3149
|
my $self = CORE::shift; |
67
|
5
|
|
|
|
|
16
|
my $divisor = type_number CORE::shift; |
68
|
5
|
|
|
|
|
181
|
return $self % $divisor; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub neg { |
72
|
1
|
|
|
1
|
1
|
3280
|
my $self = CORE::shift; |
73
|
1
|
|
|
|
|
4
|
return -$self; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
sub pow { |
77
|
1
|
|
|
1
|
1
|
3181
|
my $self = CORE::shift; |
78
|
1
|
|
|
|
|
5
|
my $n = type_number CORE::shift; |
79
|
1
|
|
|
|
|
36
|
return $self ** $n; |
80
|
|
|
|
|
|
|
} |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
sub sin { |
83
|
1
|
|
|
1
|
1
|
3063
|
my $self = CORE::shift; |
84
|
1
|
|
|
|
|
32
|
return CORE::sin $self; |
85
|
|
|
|
|
|
|
} |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub sqrt { |
88
|
1
|
|
|
1
|
1
|
3052
|
my $self = CORE::shift; |
89
|
1
|
|
|
|
|
13
|
return CORE::sqrt $self; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |