line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
## This file generated by InlineX::C2XS (version 0.22) using Inline::C (version 0.53) |
2
|
|
|
|
|
|
|
package Math::Float128; |
3
|
23
|
|
|
23
|
|
9295
|
use warnings; |
|
23
|
|
|
|
|
139
|
|
|
23
|
|
|
|
|
620
|
|
4
|
23
|
|
|
23
|
|
97
|
use strict; |
|
23
|
|
|
|
|
44
|
|
|
23
|
|
|
|
|
382
|
|
5
|
|
|
|
|
|
|
|
6
|
23
|
|
|
23
|
|
7304
|
use Math::Float128::Constant; |
|
23
|
|
|
|
|
52
|
|
|
23
|
|
|
|
|
6054
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
require Exporter; |
9
|
|
|
|
|
|
|
*import = \&Exporter::import; |
10
|
|
|
|
|
|
|
require DynaLoader; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
use overload |
13
|
23
|
|
|
|
|
572
|
'+' => \&_overload_add, |
14
|
|
|
|
|
|
|
'*' => \&_overload_mul, |
15
|
|
|
|
|
|
|
'-' => \&_overload_sub, |
16
|
|
|
|
|
|
|
'/' => \&_overload_div, |
17
|
|
|
|
|
|
|
'**' => \&_overload_pow, |
18
|
|
|
|
|
|
|
'+=' => \&_overload_add_eq, |
19
|
|
|
|
|
|
|
'*=' => \&_overload_mul_eq, |
20
|
|
|
|
|
|
|
'-=' => \&_overload_sub_eq, |
21
|
|
|
|
|
|
|
'/=' => \&_overload_div_eq, |
22
|
|
|
|
|
|
|
'**=' => \&_overload_pow_eq, |
23
|
|
|
|
|
|
|
'==' => \&_overload_equiv, |
24
|
|
|
|
|
|
|
'""' => \&_overload_string, |
25
|
|
|
|
|
|
|
'!=' => \&_overload_not_equiv, |
26
|
|
|
|
|
|
|
'bool' => \&_overload_true, |
27
|
|
|
|
|
|
|
'!' => \&_overload_not, |
28
|
|
|
|
|
|
|
'=' => \&_overload_copy, |
29
|
|
|
|
|
|
|
'<' => \&_overload_lt, |
30
|
|
|
|
|
|
|
'<=' => \&_overload_lte, |
31
|
|
|
|
|
|
|
'>' => \&_overload_gt, |
32
|
|
|
|
|
|
|
'>=' => \&_overload_gte, |
33
|
|
|
|
|
|
|
'<=>' => \&_overload_spaceship, |
34
|
|
|
|
|
|
|
'abs' => \&_overload_abs, |
35
|
|
|
|
|
|
|
'int' => \&_overload_int, |
36
|
|
|
|
|
|
|
'sqrt' => \&_overload_sqrt, |
37
|
|
|
|
|
|
|
'log' => \&_overload_log, |
38
|
|
|
|
|
|
|
'exp' => \&_overload_exp, |
39
|
|
|
|
|
|
|
'sin' => \&_overload_sin, |
40
|
|
|
|
|
|
|
'cos' => \&_overload_cos, |
41
|
|
|
|
|
|
|
'atan2' => \&_overload_atan2, |
42
|
|
|
|
|
|
|
'++' => \&_overload_inc, |
43
|
|
|
|
|
|
|
'--' => \&_overload_dec, |
44
|
23
|
|
|
23
|
|
22454
|
; |
|
23
|
|
|
|
|
20293
|
|
45
|
|
|
|
|
|
|
|
46
|
23
|
|
|
23
|
|
7247
|
use constant F128_PV_NV_BUG => Math::Float128::Constant::_has_pv_nv_bug(); |
|
23
|
|
|
|
|
42
|
|
|
23
|
|
|
|
|
2579
|
|
47
|
|
|
|
|
|
|
|
48
|
23
|
|
|
|
|
99
|
use subs qw(FLT128_DIG FLT128_MANT_DIG FLT128_MIN_EXP FLT128_MAX_EXP FLT128_MIN_10_EXP FLT128_MAX_10_EXP |
49
|
|
|
|
|
|
|
M_Eq M_LOG2Eq M_LOG10Eq M_LN2q M_LN10q M_PIq M_PI_2q M_PI_4q M_1_PIq M_2_PIq |
50
|
|
|
|
|
|
|
M_2_SQRTPIq M_SQRT2q M_SQRT1_2q |
51
|
23
|
|
|
23
|
|
10067
|
FLT128_MAX FLT128_MIN FLT128_EPSILON FLT128_DENORM_MIN); |
|
23
|
|
|
|
|
580
|
|
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
$Math::Float128::VERSION = '0.15'; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Math::Float128->DynaLoader::bootstrap($Math::Float128::VERSION); |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
@Math::Float128::EXPORT = (); |
58
|
|
|
|
|
|
|
@Math::Float128::EXPORT_OK = qw( |
59
|
|
|
|
|
|
|
F128_PV_NV_BUG |
60
|
|
|
|
|
|
|
flt128_set_prec flt128_get_prec InfF128 NaNF128 ZeroF128 UnityF128 is_NaNF128 |
61
|
|
|
|
|
|
|
is_InfF128 is_InfF128 is_ZeroF128 STRtoF128 NVtoF128 IVtoF128 UVtoF128 F128toSTR |
62
|
|
|
|
|
|
|
F128toSTRP F128toF128 F128toNV |
63
|
|
|
|
|
|
|
FLT128_DIG FLT128_MANT_DIG FLT128_MIN_EXP FLT128_MAX_EXP FLT128_MIN_10_EXP FLT128_MAX_10_EXP |
64
|
|
|
|
|
|
|
M_Eq M_LOG2Eq M_LOG10Eq M_LN2q M_LN10q M_PIq M_PI_2q M_PI_4q M_1_PIq M_2_PIq |
65
|
|
|
|
|
|
|
M_2_SQRTPIq M_SQRT2q M_SQRT1_2q |
66
|
|
|
|
|
|
|
FLT128_MAX FLT128_MIN FLT128_EPSILON FLT128_DENORM_MIN |
67
|
|
|
|
|
|
|
cmp2NV f128_bytes |
68
|
|
|
|
|
|
|
acos_F128 acosh_F128 asin_F128 asinh_F128 atan_F128 atanh_F128 atan2_F128 cbrt_F128 ceil_F128 |
69
|
|
|
|
|
|
|
copysign_F128 cosh_F128 cos_F128 erf_F128 erfc_F128 exp_F128 expm1_F128 fabs_F128 fdim_F128 |
70
|
|
|
|
|
|
|
finite_F128 floor_F128 fma_F128 fmax_F128 fmin_F128 fmod_F128 frexp_F128 hypot_F128 isinf_F128 |
71
|
|
|
|
|
|
|
ilogb_F128 isnan_F128 j0_F128 j1_F128 jn_F128 ldexp_F128 lgamma_F128 llrint_F128 llround_F128 |
72
|
|
|
|
|
|
|
log_F128 log10_F128 log2_F128 log1p_F128 lrint_F128 lround_F128 modf_F128 nan_F128 |
73
|
|
|
|
|
|
|
nearbyint_F128 nextafter_F128 pow_F128 remainder_F128 remquo_F128 rint_F128 round_F128 |
74
|
|
|
|
|
|
|
scalbln_F128 scalbn_F128 signbit_F128 sincos_F128 sinh_F128 sin_F128 sqrt_F128 tan_F128 |
75
|
|
|
|
|
|
|
tanh_F128 tgamma_F128 trunc_F128 y0_F128 y1_F128 yn_F128 |
76
|
|
|
|
|
|
|
fromSTR fromNV fromIV fromUV fromF128 |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
%Math::Float128::EXPORT_TAGS = (all => [qw( |
80
|
|
|
|
|
|
|
F128_PV_NV_BUG |
81
|
|
|
|
|
|
|
flt128_set_prec flt128_get_prec InfF128 NaNF128 ZeroF128 UnityF128 is_NaNF128 |
82
|
|
|
|
|
|
|
is_InfF128 is_InfF128 is_ZeroF128 STRtoF128 NVtoF128 IVtoF128 UVtoF128 F128toSTR |
83
|
|
|
|
|
|
|
F128toSTRP F128toF128 F128toNV |
84
|
|
|
|
|
|
|
FLT128_DIG FLT128_MANT_DIG FLT128_MIN_EXP FLT128_MAX_EXP FLT128_MIN_10_EXP FLT128_MAX_10_EXP |
85
|
|
|
|
|
|
|
M_Eq M_LOG2Eq M_LOG10Eq M_LN2q M_LN10q M_PIq M_PI_2q M_PI_4q M_1_PIq M_2_PIq |
86
|
|
|
|
|
|
|
M_2_SQRTPIq M_SQRT2q M_SQRT1_2q |
87
|
|
|
|
|
|
|
FLT128_MAX FLT128_MIN FLT128_EPSILON FLT128_DENORM_MIN |
88
|
|
|
|
|
|
|
cmp2NV f128_bytes |
89
|
|
|
|
|
|
|
acos_F128 acosh_F128 asin_F128 asinh_F128 atan_F128 atanh_F128 atan2_F128 cbrt_F128 ceil_F128 |
90
|
|
|
|
|
|
|
copysign_F128 cosh_F128 cos_F128 erf_F128 erfc_F128 exp_F128 expm1_F128 fabs_F128 fdim_F128 |
91
|
|
|
|
|
|
|
finite_F128 floor_F128 fma_F128 fmax_F128 fmin_F128 fmod_F128 frexp_F128 hypot_F128 isinf_F128 |
92
|
|
|
|
|
|
|
ilogb_F128 isnan_F128 j0_F128 j1_F128 jn_F128 ldexp_F128 lgamma_F128 llrint_F128 llround_F128 |
93
|
|
|
|
|
|
|
log_F128 log10_F128 log2_F128 log1p_F128 lrint_F128 lround_F128 modf_F128 nan_F128 |
94
|
|
|
|
|
|
|
nearbyint_F128 nextafter_F128 pow_F128 remainder_F128 remquo_F128 rint_F128 round_F128 |
95
|
|
|
|
|
|
|
scalbln_F128 scalbn_F128 signbit_F128 sincos_F128 sinh_F128 sin_F128 sqrt_F128 tan_F128 |
96
|
|
|
|
|
|
|
tanh_F128 tgamma_F128 trunc_F128 y0_F128 y1_F128 yn_F128 |
97
|
|
|
|
|
|
|
fromSTR fromNV fromIV fromUV fromF128 |
98
|
|
|
|
|
|
|
)]); |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
$Math::Float128::NOK_POK = 0; # Set to 1 to allow warnings in new() and overloaded operations when |
101
|
|
|
|
|
|
|
# a scalar that has set both NOK (NV) and POK (PV) flags is encountered |
102
|
|
|
|
|
|
|
|
103
|
23
|
|
|
23
|
0
|
18896
|
sub dl_load_flags {0} # Prevent DynaLoader from complaining and croaking |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
sub _overload_string { |
106
|
|
|
|
|
|
|
|
107
|
8
|
100
|
|
8
|
|
207
|
if(is_ZeroF128($_[0])) { |
108
|
4
|
100
|
|
|
|
13
|
return '-0' if is_ZeroF128($_[0]) < 0; |
109
|
2
|
|
|
|
|
5
|
return '0'; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
4
|
100
|
|
|
|
15
|
if(is_NaNF128($_[0])) {return 'NaN'} |
|
2
|
|
|
|
|
7
|
|
113
|
|
|
|
|
|
|
|
114
|
2
|
|
|
|
|
7
|
my $inf = is_InfF128($_[0]); |
115
|
2
|
100
|
|
|
|
6
|
return '-Inf' if $inf < 0; |
116
|
1
|
50
|
|
|
|
3
|
return 'Inf' if $inf > 0; |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
0
|
my @p = split /e/i, F128toSTR($_[0]); |
119
|
0
|
|
0
|
|
|
0
|
while(substr($p[0], -1, 1) eq '0' && substr($p[0], -2, 1) ne '.') { |
120
|
0
|
|
|
|
|
0
|
chop $p[0]; |
121
|
|
|
|
|
|
|
} |
122
|
0
|
|
|
|
|
0
|
return $p[0] . 'e' . $p[1]; |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
sub new { |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
# This function caters for 2 possibilities: |
128
|
|
|
|
|
|
|
# 1) that 'new' has been called as a method - in which |
129
|
|
|
|
|
|
|
# case there will be a maximum of 2 args |
130
|
|
|
|
|
|
|
# 2) that 'new' has been called as a function - in |
131
|
|
|
|
|
|
|
# which case there will be a maximum of 1 arg. |
132
|
|
|
|
|
|
|
# If there are no args, then we just want to return a |
133
|
|
|
|
|
|
|
# Math::Float128 object that's a NaN. |
134
|
|
|
|
|
|
|
|
135
|
450
|
50
|
|
450
|
0
|
10498
|
if(!@_) {return NaNF128()} |
|
0
|
|
|
|
|
0
|
|
136
|
|
|
|
|
|
|
|
137
|
450
|
50
|
|
|
|
721
|
if(@_ > 2) {die "More than 2 arguments supplied to new()"} |
|
0
|
|
|
|
|
0
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
# If 'new' has been called OOP style, the first arg is the string |
140
|
|
|
|
|
|
|
# "Math::Float128" which we don't need - so let's remove it. However, |
141
|
|
|
|
|
|
|
# if the first arg is a Math::Float128 object (which is a possibility), |
142
|
|
|
|
|
|
|
# then we'll get a fatal error when we check it for equivalence to |
143
|
|
|
|
|
|
|
# the string "Math::Float128". So we first need to check that it's |
144
|
|
|
|
|
|
|
# not an object - which we'll do by using the ref() function: |
145
|
450
|
100
|
100
|
|
|
1196
|
if(!ref($_[0]) && $_[0] eq "Math::Float128") { |
146
|
444
|
|
|
|
|
564
|
shift; |
147
|
444
|
100
|
|
|
|
641
|
if(!@_) {return NaNF128()} |
|
8
|
|
|
|
|
52
|
|
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
442
|
50
|
|
|
|
747
|
if(@_ > 1) {die "Too many arguments supplied to new() - expected no more than 1"} |
|
0
|
|
|
|
|
0
|
|
151
|
|
|
|
|
|
|
|
152
|
442
|
|
|
|
|
555
|
my $arg = shift; |
153
|
442
|
|
|
|
|
1083
|
my $type = _itsa($arg); |
154
|
|
|
|
|
|
|
|
155
|
442
|
100
|
|
|
|
997
|
return UVtoF128 ($arg) if $type == 1; #UV |
156
|
417
|
100
|
|
|
|
1379
|
return IVtoF128 ($arg) if $type == 2; #IV |
157
|
|
|
|
|
|
|
|
158
|
267
|
100
|
|
|
|
380
|
if($type == 4) { #PV |
159
|
98
|
100
|
|
|
|
211
|
if(_SvNOK($arg)) { |
160
|
6
|
|
|
|
|
33
|
set_nok_pok(nok_pokflag() + 1); |
161
|
6
|
50
|
|
|
|
14
|
if($Math::Float128::NOK_POK) { |
162
|
0
|
|
|
|
|
0
|
warn "Scalar passed to new() is both NV and PV. Using PV (string) value"; |
163
|
|
|
|
|
|
|
} |
164
|
|
|
|
|
|
|
} |
165
|
98
|
|
|
|
|
581
|
return STRtoF128($arg); |
166
|
|
|
|
|
|
|
} |
167
|
|
|
|
|
|
|
|
168
|
169
|
100
|
|
|
|
241
|
if($type == 3) { # NV |
169
|
|
|
|
|
|
|
|
170
|
142
|
|
|
|
|
159
|
if(F128_PV_NV_BUG) { |
171
|
|
|
|
|
|
|
if(_SvPOK($arg)) { |
172
|
|
|
|
|
|
|
set_nok_pok(nok_pokflag() + 1); |
173
|
|
|
|
|
|
|
if($Math::Float128::NOK_POK) { |
174
|
|
|
|
|
|
|
warn "Scalar passed to new() is both NV and PV. Using NV (numeric) value"; |
175
|
|
|
|
|
|
|
} |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
} |
178
|
|
|
|
|
|
|
|
179
|
142
|
100
|
|
|
|
230
|
if($arg == 0) {return NVtoF128($arg)} |
|
2
|
|
|
|
|
8
|
|
180
|
140
|
100
|
|
|
|
210
|
if($arg != $arg) { return NaNF128()} |
|
2
|
|
|
|
|
9
|
|
181
|
138
|
100
|
|
|
|
224
|
if(($arg / $arg) != 1) { # Inf |
182
|
4
|
100
|
|
|
|
8
|
if($arg < 0) {return InfF128(-1)} |
|
2
|
|
|
|
|
8
|
|
183
|
2
|
|
|
|
|
18
|
return InfF128(1); |
184
|
|
|
|
|
|
|
} |
185
|
134
|
|
|
|
|
873
|
return NVtoF128($arg); |
186
|
|
|
|
|
|
|
} |
187
|
|
|
|
|
|
|
|
188
|
27
|
50
|
|
|
|
51
|
if($type == 113) { # Math::Float128 |
189
|
27
|
|
|
|
|
125
|
return F128toF128($arg); |
190
|
|
|
|
|
|
|
} |
191
|
|
|
|
|
|
|
|
192
|
0
|
|
|
|
|
0
|
die "Bad argument given to new"; |
193
|
|
|
|
|
|
|
} |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
sub f128_bytes { |
197
|
1
|
|
|
1
|
0
|
60
|
my @ret = _f128_bytes($_[0]); |
198
|
1
|
|
|
|
|
6
|
return join '', @ret; |
199
|
|
|
|
|
|
|
} |
200
|
|
|
|
|
|
|
|
201
|
2
|
|
|
2
|
|
128
|
sub FLT128_DIG () {return _FLT128_DIG()} |
202
|
1
|
|
|
1
|
|
37
|
sub FLT128_MAX () {return _FLT128_MAX()} |
203
|
1
|
|
|
1
|
|
48
|
sub FLT128_MIN () {return _FLT128_MIN()} |
204
|
1
|
|
|
1
|
|
16
|
sub FLT128_EPSILON () {return _FLT128_EPSILON()} |
205
|
1
|
|
|
1
|
|
63
|
sub FLT128_DENORM_MIN () {return _FLT128_DENORM_MIN()} |
206
|
1
|
|
|
1
|
|
32
|
sub FLT128_MANT_DIG () {return _FLT128_MANT_DIG()} |
207
|
1
|
|
|
1
|
|
13
|
sub FLT128_MIN_EXP () {return _FLT128_MIN_EXP()} |
208
|
1
|
|
|
1
|
|
9
|
sub FLT128_MAX_EXP () {return _FLT128_MAX_EXP()} |
209
|
1
|
|
|
1
|
|
8
|
sub FLT128_MIN_10_EXP () {return _FLT128_MIN_10_EXP()} |
210
|
1
|
|
|
1
|
|
7
|
sub FLT128_MAX_10_EXP () {return _FLT128_MAX_10_EXP()} |
211
|
1
|
|
|
1
|
|
30
|
sub M_Eq () {return _M_Eq()} |
212
|
1
|
|
|
1
|
|
18
|
sub M_LOG2Eq () {return _M_LOG2Eq()} |
213
|
1
|
|
|
1
|
|
14
|
sub M_LOG10Eq () {return _M_LOG10Eq()} |
214
|
1
|
|
|
1
|
|
24
|
sub M_LN2q () {return _M_LN2q()} |
215
|
1
|
|
|
1
|
|
14
|
sub M_LN10q () {return _M_LN10q()} |
216
|
1
|
|
|
1
|
|
14
|
sub M_PIq () {return _M_PIq()} |
217
|
1
|
|
|
1
|
|
14
|
sub M_PI_2q () {return _M_PI_2q()} |
218
|
1
|
|
|
1
|
|
27
|
sub M_PI_4q () {return _M_PI_4q()} |
219
|
1
|
|
|
1
|
|
55
|
sub M_1_PIq () {return _M_1_PIq()} |
220
|
1
|
|
|
1
|
|
31
|
sub M_2_PIq () {return _M_2_PIq()} |
221
|
1
|
|
|
1
|
|
16
|
sub M_2_SQRTPIq () {return _M_2_SQRTPIq()} |
222
|
1
|
|
|
1
|
|
16
|
sub M_SQRT2q () {return _M_SQRT2q()} |
223
|
1
|
|
|
1
|
|
52
|
sub M_SQRT1_2q () {return _M_SQRT1_2q()} |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
1; |
226
|
|
|
|
|
|
|
|