tools/qlocale_tools.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qlocale_tools_p.h" -
43#include "qlocale_p.h" -
44#include "qstring.h" -
45 -
46#include <ctype.h> -
47#include <float.h> -
48#include <limits.h> -
49#include <math.h> -
50#include <stdlib.h> -
51#include <time.h> -
52 -
53#ifdef Q_OS_WINCE -
54# include "qfunctions_wince.h" // for _control87 -
55#endif -
56 -
57#if defined(Q_OS_LINUX) && !defined(__UCLIBC__) -
58# include <fenv.h> -
59#endif -
60 -
61// Sizes as defined by the ISO C99 standard - fallback -
62#ifndef LLONG_MAX -
63# define LLONG_MAX Q_INT64_C(0x7fffffffffffffff) -
64#endif -
65#ifndef LLONG_MIN -
66# define LLONG_MIN (-LLONG_MAX - Q_INT64_C(1)) -
67#endif -
68#ifndef ULLONG_MAX -
69# define ULLONG_MAX Q_UINT64_C(0xffffffffffffffff) -
70#endif -
71 -
72QT_BEGIN_NAMESPACE -
73 -
74#ifndef QT_QLOCALE_USES_FCVT -
75static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt, -
76 int *sign, char **rve, char **digits_str); -
77#endif -
78 -
79QString qulltoa(qulonglong l, int base, const QChar _zero) -
80{ -
81 ushort buff[65]; // length of MAX_ULLONG in base 2
executed (the execution status of this line is deduced): ushort buff[65];
-
82 ushort *p = buff + 65;
executed (the execution status of this line is deduced): ushort *p = buff + 65;
-
83 -
84 if (base != 10 || _zero.unicode() == '0') {
evaluated: base != 10
TRUEFALSE
yes
Evaluation Count:17830
yes
Evaluation Count:12274871
partially evaluated: _zero.unicode() == '0'
TRUEFALSE
yes
Evaluation Count:12274873
no
Evaluation Count:0
0-12274873
85 while (l != 0) {
evaluated: l != 0
TRUEFALSE
yes
Evaluation Count:21890873
yes
Evaluation Count:12292692
12292692-21890873
86 int c = l % base;
executed (the execution status of this line is deduced): int c = l % base;
-
87 -
88 --p;
executed (the execution status of this line is deduced): --p;
-
89 -
90 if (c < 10)
evaluated: c < 10
TRUEFALSE
yes
Evaluation Count:21861624
yes
Evaluation Count:29248
29248-21861624
91 *p = '0' + c;
executed: *p = '0' + c;
Execution Count:21861622
21861622
92 else -
93 *p = c - 10 + 'a';
executed: *p = c - 10 + 'a';
Execution Count:29248
29248
94 -
95 l /= base;
executed (the execution status of this line is deduced): l /= base;
-
96 }
executed: }
Execution Count:21890872
21890872
97 }
executed: }
Execution Count:12292693
12292693
98 else { -
99 while (l != 0) {
never evaluated: l != 0
0
100 int c = l % base;
never executed (the execution status of this line is deduced): int c = l % base;
-
101 -
102 *(--p) = _zero.unicode() + c;
never executed (the execution status of this line is deduced): *(--p) = _zero.unicode() + c;
-
103 -
104 l /= base;
never executed (the execution status of this line is deduced): l /= base;
-
105 }
never executed: }
0
106 }
never executed: }
0
107 -
108 return QString(reinterpret_cast<QChar *>(p), 65 - (p - buff));
executed: return QString(reinterpret_cast<QChar *>(p), 65 - (p - buff));
Execution Count:12292693
12292693
109} -
110 -
111QString qlltoa(qlonglong l, int base, const QChar zero) -
112{ -
113 return qulltoa(l < 0 ? -l : l, base, zero);
executed: return qulltoa(l < 0 ? -l : l, base, zero);
Execution Count:12249825
12249825
114} -
115 -
116QString &decimalForm(QChar zero, QChar decimal, QChar group, -
117 QString &digits, int decpt, uint precision, -
118 PrecisionMode pm, -
119 bool always_show_decpt, -
120 bool thousands_group) -
121{ -
122 if (decpt < 0) {
evaluated: decpt < 0
TRUEFALSE
yes
Evaluation Count:18517
yes
Evaluation Count:1418491
18517-1418491
123 for (int i = 0; i < -decpt; ++i)
evaluated: i < -decpt
TRUEFALSE
yes
Evaluation Count:46371
yes
Evaluation Count:18517
18517-46371
124 digits.prepend(zero);
executed: digits.prepend(zero);
Execution Count:46371
46371
125 decpt = 0;
executed (the execution status of this line is deduced): decpt = 0;
-
126 }
executed: }
Execution Count:18517
18517
127 else if (decpt > digits.length()) {
evaluated: decpt > digits.length()
TRUEFALSE
yes
Evaluation Count:378781
yes
Evaluation Count:1039710
378781-1039710
128 for (int i = digits.length(); i < decpt; ++i)
evaluated: i < decpt
TRUEFALSE
yes
Evaluation Count:522776
yes
Evaluation Count:378781
378781-522776
129 digits.append(zero);
executed: digits.append(zero);
Execution Count:522776
522776
130 }
executed: }
Execution Count:378781
378781
131 -
132 if (pm == PMDecimalDigits) {
evaluated: pm == PMDecimalDigits
TRUEFALSE
yes
Evaluation Count:1629
yes
Evaluation Count:1435379
1629-1435379
133 uint decimal_digits = digits.length() - decpt;
executed (the execution status of this line is deduced): uint decimal_digits = digits.length() - decpt;
-
134 for (uint i = decimal_digits; i < precision; ++i)
evaluated: i < precision
TRUEFALSE
yes
Evaluation Count:7031
yes
Evaluation Count:1629
1629-7031
135 digits.append(zero);
executed: digits.append(zero);
Execution Count:7031
7031
136 }
executed: }
Execution Count:1629
1629
137 else if (pm == PMSignificantDigits) {
evaluated: pm == PMSignificantDigits
TRUEFALSE
yes
Evaluation Count:2386
yes
Evaluation Count:1432993
2386-1432993
138 for (uint i = digits.length(); i < precision; ++i)
evaluated: i < precision
TRUEFALSE
yes
Evaluation Count:7938
yes
Evaluation Count:2386
2386-7938
139 digits.append(zero);
executed: digits.append(zero);
Execution Count:7938
7938
140 }
executed: }
Execution Count:2386
2386
141 else { // pm == PMChopTrailingZeros -
142 }
executed: }
Execution Count:1432993
1432993
143 -
144 if (always_show_decpt || decpt < digits.length())
evaluated: always_show_decpt
TRUEFALSE
yes
Evaluation Count:2388
yes
Evaluation Count:1434620
evaluated: decpt < digits.length()
TRUEFALSE
yes
Evaluation Count:51264
yes
Evaluation Count:1383356
2388-1434620
145 digits.insert(decpt, decimal);
executed: digits.insert(decpt, decimal);
Execution Count:53652
53652
146 -
147 if (thousands_group) {
evaluated: thousands_group
TRUEFALSE
yes
Evaluation Count:5756
yes
Evaluation Count:1431252
5756-1431252
148 for (int i = decpt - 3; i > 0; i -= 3)
evaluated: i > 0
TRUEFALSE
yes
Evaluation Count:2737
yes
Evaluation Count:5756
2737-5756
149 digits.insert(i, group);
executed: digits.insert(i, group);
Execution Count:2737
2737
150 }
executed: }
Execution Count:5756
5756
151 -
152 if (decpt == 0)
evaluated: decpt == 0
TRUEFALSE
yes
Evaluation Count:47367
yes
Evaluation Count:1389641
47367-1389641
153 digits.prepend(zero);
executed: digits.prepend(zero);
Execution Count:47367
47367
154 -
155 return digits;
executed: return digits;
Execution Count:1437008
1437008
156} -
157 -
158QString &exponentForm(QChar zero, QChar decimal, QChar exponential, -
159 QChar group, QChar plus, QChar minus, -
160 QString &digits, int decpt, uint precision, -
161 PrecisionMode pm, -
162 bool always_show_decpt) -
163{ -
164 int exp = decpt - 1;
executed (the execution status of this line is deduced): int exp = decpt - 1;
-
165 -
166 if (pm == PMDecimalDigits) {
evaluated: pm == PMDecimalDigits
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:68259
11-68259
167 for (uint i = digits.length(); i < precision + 1; ++i)
evaluated: i < precision + 1
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:11
11-14
168 digits.append(zero);
executed: digits.append(zero);
Execution Count:14
14
169 }
executed: }
Execution Count:11
11
170 else if (pm == PMSignificantDigits) {
evaluated: pm == PMSignificantDigits
TRUEFALSE
yes
Evaluation Count:2224
yes
Evaluation Count:66035
2224-66035
171 for (uint i = digits.length(); i < precision; ++i)
evaluated: i < precision
TRUEFALSE
yes
Evaluation Count:1920
yes
Evaluation Count:2224
1920-2224
172 digits.append(zero);
executed: digits.append(zero);
Execution Count:1920
1920
173 }
executed: }
Execution Count:2224
2224
174 else { // pm == PMChopTrailingZeros -
175 }
executed: }
Execution Count:66035
66035
176 -
177 if (always_show_decpt || digits.length() > 1)
evaluated: always_show_decpt
TRUEFALSE
yes
Evaluation Count:2226
yes
Evaluation Count:66044
evaluated: digits.length() > 1
TRUEFALSE
yes
Evaluation Count:64723
yes
Evaluation Count:1321
1321-66044
178 digits.insert(1, decimal);
executed: digits.insert(1, decimal);
Execution Count:66949
66949
179 -
180 digits.append(exponential);
executed (the execution status of this line is deduced): digits.append(exponential);
-
181 digits.append(QLocalePrivate::longLongToString(zero, group, plus, minus,
executed (the execution status of this line is deduced): digits.append(QLocalePrivate::longLongToString(zero, group, plus, minus,
-
182 exp, 2, 10, -1, QLocalePrivate::AlwaysShowSign));
executed (the execution status of this line is deduced): exp, 2, 10, -1, QLocalePrivate::AlwaysShowSign));
-
183 -
184 return digits;
executed: return digits;
Execution Count:68270
68270
185} -
186 -
187// Removes thousand-group separators in "C" locale. -
188bool removeGroupSeparators(QLocalePrivate::CharBuff *num) -
189{ -
190 int group_cnt = 0; // counts number of group chars
executed (the execution status of this line is deduced): int group_cnt = 0;
-
191 int decpt_idx = -1;
executed (the execution status of this line is deduced): int decpt_idx = -1;
-
192 -
193 char *data = num->data();
executed (the execution status of this line is deduced): char *data = num->data();
-
194 int l = qstrlen(data);
executed (the execution status of this line is deduced): int l = qstrlen(data);
-
195 -
196 // Find the decimal point and check if there are any group chars -
197 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
198 for (; i < l; ++i) {
evaluated: i < l
TRUEFALSE
yes
Evaluation Count:34215
yes
Evaluation Count:13420
13420-34215
199 char c = data[i];
executed (the execution status of this line is deduced): char c = data[i];
-
200 -
201 if (c == ',') {
evaluated: c == ','
TRUEFALSE
yes
Evaluation Count:132
yes
Evaluation Count:34083
132-34083
202 if (i == 0 || data[i - 1] < '0' || data[i - 1] > '9')
evaluated: i == 0
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:125
evaluated: data[i - 1] < '0'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:124
partially evaluated: data[i - 1] > '9'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:124
0-125
203 return false;
executed: return false;
Execution Count:8
8
204 if (i == l - 1 || data[i + 1] < '0' || data[i + 1] > '9')
evaluated: i == l - 1
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:114
evaluated: data[i + 1] < '0'
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:109
evaluated: data[i + 1] > '9'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:108
1-114
205 return false;
executed: return false;
Execution Count:16
16
206 ++group_cnt;
executed (the execution status of this line is deduced): ++group_cnt;
-
207 }
executed: }
Execution Count:108
108
208 else if (c == '.') {
evaluated: c == '.'
TRUEFALSE
yes
Evaluation Count:822
yes
Evaluation Count:33261
822-33261
209 // Fail if more than one decimal points -
210 if (decpt_idx != -1)
evaluated: decpt_idx != -1
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:821
1-821
211 return false;
executed: return false;
Execution Count:1
1
212 decpt_idx = i;
executed (the execution status of this line is deduced): decpt_idx = i;
-
213 } else if (c == 'e' || c == 'E') {
executed: }
Execution Count:821
evaluated: c == 'e'
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:33228
partially evaluated: c == 'E'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33228
0-33228
214 // an 'e' or 'E' - if we have not encountered a decimal -
215 // point, this is where it "is". -
216 if (decpt_idx == -1)
evaluated: decpt_idx == -1
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:8
8-25
217 decpt_idx = i;
executed: decpt_idx = i;
Execution Count:25
25
218 }
executed: }
Execution Count:33
33
219 } -
220 -
221 // If no group chars, we're done -
222 if (group_cnt == 0)
evaluated: group_cnt == 0
TRUEFALSE
yes
Evaluation Count:13336
yes
Evaluation Count:84
84-13336
223 return true;
executed: return true;
Execution Count:13336
13336
224 -
225 // No decimal point means that it "is" at the end of the string -
226 if (decpt_idx == -1)
evaluated: decpt_idx == -1
TRUEFALSE
yes
Evaluation Count:63
yes
Evaluation Count:21
21-63
227 decpt_idx = l;
executed: decpt_idx = l;
Execution Count:63
63
228 -
229 i = 0;
executed (the execution status of this line is deduced): i = 0;
-
230 while (i < l && group_cnt > 0) {
partially evaluated: i < l
TRUEFALSE
yes
Evaluation Count:262
no
Evaluation Count:0
evaluated: group_cnt > 0
TRUEFALSE
yes
Evaluation Count:225
yes
Evaluation Count:37
0-262
231 char c = data[i];
executed (the execution status of this line is deduced): char c = data[i];
-
232 -
233 if (c == ',') {
evaluated: c == ','
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:158
67-158
234 // Don't allow group chars after the decimal point -
235 if (i > decpt_idx)
evaluated: i > decpt_idx
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:66
1-66
236 return false;
executed: return false;
Execution Count:1
1
237 -
238 // Check that it is placed correctly relative to the decpt -
239 if ((decpt_idx - i) % 4 != 0)
evaluated: (decpt_idx - i) % 4 != 0
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:53
13-53
240 return false;
executed: return false;
Execution Count:13
13
241 -
242 // Remove it -
243 memmove(data + i, data + i + 1, l - i - 1);
executed (the execution status of this line is deduced): memmove(data + i, data + i + 1, l - i - 1);
-
244 data[--l] = '\0';
executed (the execution status of this line is deduced): data[--l] = '\0';
-
245 -
246 --group_cnt;
executed (the execution status of this line is deduced): --group_cnt;
-
247 --decpt_idx;
executed (the execution status of this line is deduced): --decpt_idx;
-
248 } else {
executed: }
Execution Count:53
53
249 // Check that we are not missing a separator -
250 if (i < decpt_idx
evaluated: i < decpt_idx
TRUEFALSE
yes
Evaluation Count:156
yes
Evaluation Count:2
2-156
251 && (decpt_idx - i) % 4 == 0
evaluated: (decpt_idx - i) % 4 == 0
TRUEFALSE
yes
Evaluation Count:38
yes
Evaluation Count:118
38-118
252 && !(i == 0 && (c == '-' || c == '+'))) // check for negative or positive sign at start of string
evaluated: i == 0
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:1
evaluated: c == '-'
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:36
evaluated: c == '+'
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:32
1-37
253 return false;
executed: return false;
Execution Count:33
33
254 ++i;
executed (the execution status of this line is deduced): ++i;
-
255 }
executed: }
Execution Count:125
125
256 } -
257 -
258 return true;
executed: return true;
Execution Count:37
37
259} -
260 -
261/*- -
262 * Copyright (c) 1992, 1993 -
263 * The Regents of the University of California. All rights reserved. -
264 * -
265 * Redistribution and use in source and binary forms, with or without -
266 * modification, are permitted provided that the following conditions -
267 * are met: -
268 * 1. Redistributions of source code must retain the above copyright -
269 * notice, this list of conditions and the following disclaimer. -
270 * 2. Redistributions in binary form must reproduce the above copyright -
271 * notice, this list of conditions and the following disclaimer in the -
272 * documentation and/or other materials provided with the distribution. -
273 * 3. All advertising materials mentioning features or use of this software -
274 * must display the following acknowledgment: -
275 * This product includes software developed by the University of -
276 * California, Berkeley and its contributors. -
277 * 4. Neither the name of the University nor the names of its contributors -
278 * may be used to endorse or promote products derived from this software -
279 * without specific prior written permission. -
280 * -
281 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -
282 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -
283 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -
284 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -
285 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -
286 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -
287 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -
288 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -
289 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -
290 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -
291 * SUCH DAMAGE. -
292 */ -
293 -
294// static char sccsid[] = "@(#)strtouq.c 8.1 (Berkeley) 6/4/93"; -
295// "$FreeBSD: src/lib/libc/stdlib/strtoull.c,v 1.5.2.1 2001/03/02 09:45:20 obrien Exp $"; -
296 -
297/* -
298 * Convert a string to an unsigned long long integer. -
299 * -
300 * Ignores `locale' stuff. Assumes that the upper and lower case -
301 * alphabets and digits are each contiguous. -
302 */ -
303qulonglong qstrtoull(const char *nptr, const char **endptr, register int base, bool *ok) -
304{ -
305 register const char *s = nptr;
executed (the execution status of this line is deduced): register const char *s = nptr;
-
306 register qulonglong acc;
executed (the execution status of this line is deduced): register qulonglong acc;
-
307 register unsigned char c;
executed (the execution status of this line is deduced): register unsigned char c;
-
308 register qulonglong qbase, cutoff;
executed (the execution status of this line is deduced): register qulonglong qbase, cutoff;
-
309 register int any, cutlim;
executed (the execution status of this line is deduced): register int any, cutlim;
-
310 -
311 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:51373
no
Evaluation Count:0
0-51373
312 *ok = true;
executed: *ok = true;
Execution Count:51362
51362
313 -
314 /* -
315 * See strtoq for comments as to the logic used. -
316 */ -
317 s = nptr;
executed (the execution status of this line is deduced): s = nptr;
-
318 do { -
319 c = *s++;
executed (the execution status of this line is deduced): c = *s++;
-
320 } while (isspace(c));
executed: }
Execution Count:51383
partially evaluated: isspace(c)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:51347
0-51383
321 if (c == '-') {
evaluated: c == '-'
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:51311
25-51311
322 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
323 *ok = false;
executed: *ok = false;
Execution Count:25
25
324 if (endptr != 0)
partially evaluated: endptr != 0
TRUEFALSE
yes
Evaluation Count:25
no
Evaluation Count:0
0-25
325 *endptr = s - 1;
executed: *endptr = s - 1;
Execution Count:25
25
326 return 0;
executed: return 0;
Execution Count:25
25
327 } else { -
328 if (c == '+')
partially evaluated: c == '+'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:51310
0-51310
329 c = *s++;
never executed: c = *s++;
0
330 }
executed: }
Execution Count:51307
51307
331 if ((base == 0 || base == 16) &&
evaluated: base == 0
TRUEFALSE
yes
Evaluation Count:22459
yes
Evaluation Count:28847
evaluated: base == 16
TRUEFALSE
yes
Evaluation Count:13393
yes
Evaluation Count:15454
13393-28847
332 c == '0' && (*s == 'x' || *s == 'X')) {
evaluated: c == '0'
TRUEFALSE
yes
Evaluation Count:2423
yes
Evaluation Count:33429
evaluated: *s == 'x'
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:2403
partially evaluated: *s == 'X'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2403
0-33429
333 c = s[1];
executed (the execution status of this line is deduced): c = s[1];
-
334 s += 2;
executed (the execution status of this line is deduced): s += 2;
-
335 base = 16;
executed (the execution status of this line is deduced): base = 16;
-
336 }
executed: }
Execution Count:20
20
337 if (base == 0)
evaluated: base == 0
TRUEFALSE
yes
Evaluation Count:22459
yes
Evaluation Count:28855
22459-28855
338 base = c == '0' ? 8 : 10;
executed: base = c == '0' ? 8 : 10;
Execution Count:22476
evaluated: c == '0'
TRUEFALSE
yes
Evaluation Count:2270
yes
Evaluation Count:20202
2270-22476
339 qbase = unsigned(base);
executed (the execution status of this line is deduced): qbase = unsigned(base);
-
340 cutoff = qulonglong(ULLONG_MAX) / qbase;
executed (the execution status of this line is deduced): cutoff = qulonglong((9223372036854775807LL * 2ULL + 1)) / qbase;
-
341 cutlim = qulonglong(ULLONG_MAX) % qbase;
executed (the execution status of this line is deduced): cutlim = qulonglong((9223372036854775807LL * 2ULL + 1)) % qbase;
-
342 for (acc = 0, any = 0;; c = *s++) {
executed (the execution status of this line is deduced): for (acc = 0, any = 0;; c = *s++) {
-
343 if (!isascii(c))
partially evaluated: !isascii(c)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:115485
0-115485
344 break;
never executed: break;
0
345 if (isdigit(c))
evaluated: isdigit(c)
TRUEFALSE
yes
Evaluation Count:50494
yes
Evaluation Count:64989
50494-64989
346 c -= '0';
executed: c -= '0';
Execution Count:50494
50494
347 else if (isalpha(c))
evaluated: isalpha(c)
TRUEFALSE
yes
Evaluation Count:29006
yes
Evaluation Count:35994
29006-35994
348 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
executed: c -= isupper(c) ? 'A' - 10 : 'a' - 10;
Execution Count:29006
evaluated: isupper(c)
TRUEFALSE
yes
Evaluation Count:267
yes
Evaluation Count:28723
267-29006
349 else -
350 break;
executed: break;
Execution Count:35994
35994
351 if (c >= base)
evaluated: c >= base
TRUEFALSE
yes
Evaluation Count:15411
yes
Evaluation Count:64075
15411-64075
352 break;
executed: break;
Execution Count:15418
15418
353 if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
partially evaluated: any < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:64075
partially evaluated: acc > cutoff
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:64075
evaluated: acc == cutoff
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:64067
evaluated: c > cutlim
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5
0-64075
354 any = -1;
executed: any = -1;
Execution Count:3
3
355 else { -
356 any = 1;
executed (the execution status of this line is deduced): any = 1;
-
357 acc *= qbase;
executed (the execution status of this line is deduced): acc *= qbase;
-
358 acc += c;
executed (the execution status of this line is deduced): acc += c;
-
359 }
executed: }
Execution Count:64073
64073
360 } -
361 if (any == 0) {
evaluated: any == 0
TRUEFALSE
yes
Evaluation Count:16286
yes
Evaluation Count:35115
16286-35115
362 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:16285
no
Evaluation Count:0
0-16285
363 *ok = false;
executed: *ok = false;
Execution Count:16292
16292
364 } else if (any < 0) {
executed: }
Execution Count:16300
evaluated: any < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:35112
3-35112
365 acc = ULLONG_MAX;
executed (the execution status of this line is deduced): acc = (9223372036854775807LL * 2ULL + 1);
-
366 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
367 *ok = false;
executed: *ok = false;
Execution Count:3
3
368 }
executed: }
Execution Count:3
3
369 if (endptr != 0)
partially evaluated: endptr != 0
TRUEFALSE
yes
Evaluation Count:51394
no
Evaluation Count:0
0-51394
370 *endptr = (any ? s - 1 : nptr);
executed: *endptr = (any ? s - 1 : nptr);
Execution Count:51348
evaluated: any
TRUEFALSE
yes
Evaluation Count:35115
yes
Evaluation Count:16250
16250-51348
371 return acc;
executed: return acc;
Execution Count:51401
51401
372} -
373 -
374 -
375// "$FreeBSD: src/lib/libc/stdlib/strtoll.c,v 1.5.2.1 2001/03/02 09:45:20 obrien Exp $"; -
376 -
377 -
378/* -
379 * Convert a string to a long long integer. -
380 * -
381 * Ignores `locale' stuff. Assumes that the upper and lower case -
382 * alphabets and digits are each contiguous. -
383 */ -
384qlonglong qstrtoll(const char *nptr, const char **endptr, register int base, bool *ok) -
385{ -
386 register const char *s;
executed (the execution status of this line is deduced): register const char *s;
-
387 register qulonglong acc;
executed (the execution status of this line is deduced): register qulonglong acc;
-
388 register unsigned char c;
executed (the execution status of this line is deduced): register unsigned char c;
-
389 register qulonglong qbase, cutoff;
executed (the execution status of this line is deduced): register qulonglong qbase, cutoff;
-
390 register int neg, any, cutlim;
executed (the execution status of this line is deduced): register int neg, any, cutlim;
-
391 -
392 /* -
393 * Skip white space and pick up leading +/- sign if any. -
394 * If base is 0, allow 0x for hex and 0 for octal, else -
395 * assume decimal; if base is already 16, allow 0x. -
396 */ -
397 s = nptr;
executed (the execution status of this line is deduced): s = nptr;
-
398 do { -
399 c = *s++;
executed (the execution status of this line is deduced): c = *s++;
-
400 } while (isspace(c));
executed: }
Execution Count:254823
partially evaluated: isspace(c)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:254823
0-254823
401 if (c == '-') {
evaluated: c == '-'
TRUEFALSE
yes
Evaluation Count:238
yes
Evaluation Count:254585
238-254585
402 neg = 1;
executed (the execution status of this line is deduced): neg = 1;
-
403 c = *s++;
executed (the execution status of this line is deduced): c = *s++;
-
404 } else {
executed: }
Execution Count:238
238
405 neg = 0;
executed (the execution status of this line is deduced): neg = 0;
-
406 if (c == '+')
evaluated: c == '+'
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:254575
10-254575
407 c = *s++;
executed: c = *s++;
Execution Count:10
10
408 }
executed: }
Execution Count:254585
254585
409 if ((base == 0 || base == 16) &&
evaluated: base == 0
TRUEFALSE
yes
Evaluation Count:53
yes
Evaluation Count:254770
evaluated: base == 16
TRUEFALSE
yes
Evaluation Count:176337
yes
Evaluation Count:78434
53-254770
410 c == '0' && (*s == 'x' || *s == 'X')) {
evaluated: c == '0'
TRUEFALSE
yes
Evaluation Count:49079
yes
Evaluation Count:127311
evaluated: *s == 'x'
TRUEFALSE
yes
Evaluation Count:41
yes
Evaluation Count:49038
partially evaluated: *s == 'X'
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:49038
0-127311
411 c = s[1];
executed (the execution status of this line is deduced): c = s[1];
-
412 s += 2;
executed (the execution status of this line is deduced): s += 2;
-
413 base = 16;
executed (the execution status of this line is deduced): base = 16;
-
414 }
executed: }
Execution Count:41
41
415 if (base == 0)
evaluated: base == 0
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:254789
34-254789
416 base = c == '0' ? 8 : 10;
executed: base = c == '0' ? 8 : 10;
Execution Count:34
evaluated: c == '0'
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:15
15-34
417 -
418 /* -
419 * Compute the cutoff value between legal numbers and illegal -
420 * numbers. That is the largest legal value, divided by the -
421 * base. An input number that is greater than this value, if -
422 * followed by a legal input character, is too big. One that -
423 * is equal to this value may be valid or not; the limit -
424 * between valid and invalid numbers is then based on the last -
425 * digit. For instance, if the range for quads is -
426 * [-9223372036854775808..9223372036854775807] and the input base -
427 * is 10, cutoff will be set to 922337203685477580 and cutlim to -
428 * either 7 (neg==0) or 8 (neg==1), meaning that if we have -
429 * accumulated a value > 922337203685477580, or equal but the -
430 * next digit is > 7 (or 8), the number is too big, and we will -
431 * return a range error. -
432 * -
433 * Set any if any `digits' consumed; make it negative to indicate -
434 * overflow. -
435 */ -
436 qbase = unsigned(base);
executed (the execution status of this line is deduced): qbase = unsigned(base);
-
437 cutoff = neg ? qulonglong(0-(LLONG_MIN + LLONG_MAX)) + LLONG_MAX : LLONG_MAX;
evaluated: neg
TRUEFALSE
yes
Evaluation Count:238
yes
Evaluation Count:254585
238-254585
438 cutlim = cutoff % qbase;
executed (the execution status of this line is deduced): cutlim = cutoff % qbase;
-
439 cutoff /= qbase;
executed (the execution status of this line is deduced): cutoff /= qbase;
-
440 for (acc = 0, any = 0;; c = *s++) {
executed (the execution status of this line is deduced): for (acc = 0, any = 0;; c = *s++) {
-
441 if (!isascii(c))
partially evaluated: !isascii(c)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1163443
0-1163443
442 break;
never executed: break;
0
443 if (isdigit(c))
evaluated: isdigit(c)
TRUEFALSE
yes
Evaluation Count:629352
yes
Evaluation Count:534092
534092-629352
444 c -= '0';
executed: c -= '0';
Execution Count:629352
629352
445 else if (isalpha(c))
evaluated: isalpha(c)
TRUEFALSE
yes
Evaluation Count:279433
yes
Evaluation Count:254657
254657-279433
446 c -= isupper(c) ? 'A' - 10 : 'a' - 10;
executed: c -= isupper(c) ? 'A' - 10 : 'a' - 10;
Execution Count:279433
evaluated: isupper(c)
TRUEFALSE
yes
Evaluation Count:177974
yes
Evaluation Count:101459
101459-279433
447 else -
448 break;
executed: break;
Execution Count:254657
254657
449 if (c >= base)
evaluated: c >= base
TRUEFALSE
yes
Evaluation Count:164
yes
Evaluation Count:908621
164-908621
450 break;
executed: break;
Execution Count:164
164
451 if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim))
partially evaluated: any < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:908622
evaluated: acc > cutoff
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:908620
evaluated: acc == cutoff
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:908611
evaluated: c > cutlim
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8
0-908622
452 any = -1;
executed: any = -1;
Execution Count:4
4
453 else { -
454 any = 1;
executed (the execution status of this line is deduced): any = 1;
-
455 acc *= qbase;
executed (the execution status of this line is deduced): acc *= qbase;
-
456 acc += c;
executed (the execution status of this line is deduced): acc += c;
-
457 }
executed: }
Execution Count:908619
908619
458 } -
459 if (any < 0) {
evaluated: any < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:254817
4-254817
460 acc = neg ? LLONG_MIN : LLONG_MAX;
evaluated: neg
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
461 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
462 *ok = false;
executed: *ok = false;
Execution Count:4
4
463 } else if (neg) {
executed: }
Execution Count:4
evaluated: neg
TRUEFALSE
yes
Evaluation Count:236
yes
Evaluation Count:254581
4-254581
464 acc = (~acc) + 1;
executed (the execution status of this line is deduced): acc = (~acc) + 1;
-
465 }
executed: }
Execution Count:236
236
466 if (endptr != 0)
partially evaluated: endptr != 0
TRUEFALSE
yes
Evaluation Count:254821
no
Evaluation Count:0
0-254821
467 *endptr = (any >= 0 ? s - 1 : nptr);
executed: *endptr = (any >= 0 ? s - 1 : nptr);
Execution Count:254821
evaluated: any >= 0
TRUEFALSE
yes
Evaluation Count:254817
yes
Evaluation Count:4
4-254821
468 -
469 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:254822
no
Evaluation Count:0
0-254822
470 *ok = any > 0;
executed: *ok = any > 0;
Execution Count:254821
254821
471 -
472 return acc;
executed: return acc;
Execution Count:254821
254821
473} -
474 -
475#ifndef QT_QLOCALE_USES_FCVT -
476 -
477/* From: NetBSD: strtod.c,v 1.26 1998/02/03 18:44:21 perry Exp */ -
478/* $FreeBSD: src/lib/libc/stdlib/netbsd_strtod.c,v 1.2.2.2 2001/03/02 17:14:15 tegge Exp $ */ -
479 -
480/* Please send bug reports to -
481 David M. Gay -
482 AT&T Bell Laboratories, Room 2C-463 -
483 600 Mountain Avenue -
484 Murray Hill, NJ 07974-2070 -
485 U.S.A. -
486 dmg@research.att.com or research!dmg -
487 */ -
488 -
489/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. -
490 * -
491 * This strtod returns a nearest machine number to the input decimal -
492 * string (or sets errno to ERANGE). With IEEE arithmetic, ties are -
493 * broken by the IEEE round-even rule. Otherwise ties are broken by -
494 * biased rounding (add half and chop). -
495 * -
496 * Inspired loosely by William D. Clinger's paper "How to Read Floating -
497 * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. -
498 * -
499 * Modifications: -
500 * -
501 * 1. We only require IEEE, IBM, or VAX double-precision -
502 * arithmetic (not IEEE double-extended). -
503 * 2. We get by with floating-point arithmetic in a case that -
504 * Clinger missed -- when we're computing d * 10^n -
505 * for a small integer d and the integer n is not too -
506 * much larger than 22 (the maximum integer k for which -
507 * we can represent 10^k exactly), we may be able to -
508 * compute (d*10^k) * 10^(e-k) with just one roundoff. -
509 * 3. Rather than a bit-at-a-time adjustment of the binary -
510 * result in the hard case, we use floating-point -
511 * arithmetic to determine the adjustment to within -
512 * one bit; only in really hard cases do we need to -
513 * compute a second residual. -
514 * 4. Because of 3., we don't need a large table of powers of 10 -
515 * for ten-to-e (just some small tables, e.g. of 10^k -
516 * for 0 <= k <= 22). -
517 */ -
518 -
519/* -
520 * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least -
521 * significant byte has the lowest address. -
522 * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most -
523 * significant byte has the lowest address. -
524 * #define Long int on machines with 32-bit ints and 64-bit longs. -
525 * #define Sudden_Underflow for IEEE-format machines without gradual -
526 * underflow (i.e., that flush to zero on underflow). -
527 * #define IBM for IBM mainframe-style floating-point arithmetic. -
528 * #define VAX for VAX-style floating-point arithmetic. -
529 * #define Unsigned_Shifts if >> does treats its left operand as unsigned. -
530 * #define No_leftright to omit left-right logic in fast floating-point -
531 * computation of dtoa. -
532 * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. -
533 * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines -
534 * that use extended-precision instructions to compute rounded -
535 * products and quotients) with IBM. -
536 * #define ROUND_BIASED for IEEE-format with biased rounding. -
537 * #define Inaccurate_Divide for IEEE-format with correctly rounded -
538 * products but inaccurate quotients, e.g., for Intel i860. -
539 * #define Just_16 to store 16 bits per 32-bit Long when doing high-precision -
540 * integer arithmetic. Whether this speeds things up or slows things -
541 * down depends on the machine and the number being converted. -
542 * #define KR_headers for old-style C function headers. -
543 * #define Bad_float_h if your system lacks a float.h or if it does not -
544 * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, -
545 * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. -
546 * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) -
547 * if memory is available and otherwise does something you deem -
548 * appropriate. If MALLOC is undefined, malloc will be invoked -
549 * directly -- and assumed always to succeed. -
550 */ -
551 -
552#if defined(LIBC_SCCS) && !defined(lint) -
553__RCSID("$NetBSD: strtod.c,v 1.26 1998/02/03 18:44:21 perry Exp $"); -
554#endif /* LIBC_SCCS and not lint */ -
555 -
556/* -
557#if defined(__m68k__) || defined(__sparc__) || defined(__i386__) || \ -
558 defined(__mips__) || defined(__ns32k__) || defined(__alpha__) || \ -
559 defined(__powerpc__) || defined(Q_OS_WIN) || defined(Q_OS_DARWIN) || defined(Q_OS_MAC) || \ -
560 defined(mips) || defined(Q_OS_AIX) || defined(Q_OS_SOLARIS) -
561# define IEEE_BIG_OR_LITTLE_ENDIAN 1 -
562#endif -
563*/ -
564 -
565// *All* of our architectures have IEEE arithmetic, don't they? -
566#define IEEE_BIG_OR_LITTLE_ENDIAN 1 -
567 -
568#ifdef __arm32__ -
569/* -
570 * Although the CPU is little endian the FP has different -
571 * byte and word endianness. The byte order is still little endian -
572 * but the word order is big endian. -
573 */ -
574#define IEEE_BIG_OR_LITTLE_ENDIAN -
575#endif -
576 -
577#ifdef vax -
578#define VAX -
579#endif -
580 -
581#define Long qint32 -
582#define ULong quint32 -
583 -
584#define MALLOC malloc -
585 -
586#ifdef BSD_QDTOA_DEBUG -
587QT_BEGIN_INCLUDE_NAMESPACE -
588#include <stdio.h> -
589QT_END_INCLUDE_NAMESPACE -
590 -
591#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} -
592#endif -
593 -
594#ifdef Unsigned_Shifts -
595#define Sign_Extend(a,b) if (b < 0) a |= 0xffff0000; -
596#else -
597#define Sign_Extend(a,b) /*no-op*/ -
598#endif -
599 -
600#if (defined(IEEE_BIG_OR_LITTLE_ENDIAN) + defined(VAX) + defined(IBM)) != 1 -
601#error Exactly one of IEEE_BIG_OR_LITTLE_ENDIAN, VAX, or IBM should be defined. -
602#endif -
603 -
604static inline ULong getWord0(const NEEDS_VOLATILE double x) -
605{ -
606 const NEEDS_VOLATILE uchar *ptr = reinterpret_cast<const NEEDS_VOLATILE uchar *>(&x);
executed (the execution status of this line is deduced): const volatile uchar *ptr = reinterpret_cast<const volatile uchar *>(&x);
-
607 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
partially evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:13725407
0-13725407
608 return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3];
never executed: return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3];
0
609 } else { -
610 return (ptr[7]<<24) + (ptr[6]<<16) + (ptr[5]<<8) + ptr[4];
executed: return (ptr[7]<<24) + (ptr[6]<<16) + (ptr[5]<<8) + ptr[4];
Execution Count:13725407
13725407
611 } -
612} -
613 -
614static inline void setWord0(NEEDS_VOLATILE double *x, ULong l) -
615{ -
616 NEEDS_VOLATILE uchar *ptr = reinterpret_cast<NEEDS_VOLATILE uchar *>(x);
executed (the execution status of this line is deduced): volatile uchar *ptr = reinterpret_cast<volatile uchar *>(x);
-
617 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
partially evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6325072
0-6325072
618 ptr[0] = uchar(l>>24);
never executed (the execution status of this line is deduced): ptr[0] = uchar(l>>24);
-
619 ptr[1] = uchar(l>>16);
never executed (the execution status of this line is deduced): ptr[1] = uchar(l>>16);
-
620 ptr[2] = uchar(l>>8);
never executed (the execution status of this line is deduced): ptr[2] = uchar(l>>8);
-
621 ptr[3] = uchar(l);
never executed (the execution status of this line is deduced): ptr[3] = uchar(l);
-
622 } else {
never executed: }
0
623 ptr[7] = uchar(l>>24);
executed (the execution status of this line is deduced): ptr[7] = uchar(l>>24);
-
624 ptr[6] = uchar(l>>16);
executed (the execution status of this line is deduced): ptr[6] = uchar(l>>16);
-
625 ptr[5] = uchar(l>>8);
executed (the execution status of this line is deduced): ptr[5] = uchar(l>>8);
-
626 ptr[4] = uchar(l);
executed (the execution status of this line is deduced): ptr[4] = uchar(l);
-
627 }
executed: }
Execution Count:6325072
6325072
628} -
629 -
630static inline ULong getWord1(const NEEDS_VOLATILE double x) -
631{ -
632 const NEEDS_VOLATILE uchar *ptr = reinterpret_cast<const NEEDS_VOLATILE uchar *>(&x);
executed (the execution status of this line is deduced): const volatile uchar *ptr = reinterpret_cast<const volatile uchar *>(&x);
-
633 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
partially evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1463306
0-1463306
634 return (ptr[4]<<24) + (ptr[5]<<16) + (ptr[6]<<8) + ptr[7];
never executed: return (ptr[4]<<24) + (ptr[5]<<16) + (ptr[6]<<8) + ptr[7];
0
635 } else { -
636 return (ptr[3]<<24) + (ptr[2]<<16) + (ptr[1]<<8) + ptr[0];
executed: return (ptr[3]<<24) + (ptr[2]<<16) + (ptr[1]<<8) + ptr[0];
Execution Count:1463306
1463306
637 } -
638} -
639static inline void setWord1(NEEDS_VOLATILE double *x, ULong l) -
640{ -
641 NEEDS_VOLATILE uchar *ptr = reinterpret_cast<uchar NEEDS_VOLATILE *>(x);
executed (the execution status of this line is deduced): volatile uchar *ptr = reinterpret_cast<uchar volatile *>(x);
-
642 if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
partially evaluated: QSysInfo::ByteOrder == QSysInfo::BigEndian
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:400
0-400
643 ptr[4] = uchar(l>>24);
never executed (the execution status of this line is deduced): ptr[4] = uchar(l>>24);
-
644 ptr[5] = uchar(l>>16);
never executed (the execution status of this line is deduced): ptr[5] = uchar(l>>16);
-
645 ptr[6] = uchar(l>>8);
never executed (the execution status of this line is deduced): ptr[6] = uchar(l>>8);
-
646 ptr[7] = uchar(l);
never executed (the execution status of this line is deduced): ptr[7] = uchar(l);
-
647 } else {
never executed: }
0
648 ptr[3] = uchar(l>>24);
executed (the execution status of this line is deduced): ptr[3] = uchar(l>>24);
-
649 ptr[2] = uchar(l>>16);
executed (the execution status of this line is deduced): ptr[2] = uchar(l>>16);
-
650 ptr[1] = uchar(l>>8);
executed (the execution status of this line is deduced): ptr[1] = uchar(l>>8);
-
651 ptr[0] = uchar(l);
executed (the execution status of this line is deduced): ptr[0] = uchar(l);
-
652 }
executed: }
Execution Count:400
400
653} -
654 -
655static inline void Storeinc(ULong *&a, const ULong &b, const ULong &c) -
656{ -
657 -
658 *a = (ushort(b) << 16) | ushort(c);
executed (the execution status of this line is deduced): *a = (ushort(b) << 16) | ushort(c);
-
659 ++a;
executed (the execution status of this line is deduced): ++a;
-
660}
executed: }
Execution Count:972173
972173
661 -
662/* #define P DBL_MANT_DIG */ -
663/* Ten_pmax = floor(P*log(2)/log(5)) */ -
664/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ -
665/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ -
666/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ -
667 -
668#if defined(IEEE_BIG_OR_LITTLE_ENDIAN) -
669#define Exp_shift 20 -
670#define Exp_shift1 20 -
671#define Exp_msk1 0x100000 -
672#define Exp_msk11 0x100000 -
673#define Exp_mask 0x7ff00000 -
674#define P 53 -
675#define Bias 1023 -
676#define IEEE_Arith -
677#define Emin (-1022) -
678#define Exp_1 0x3ff00000 -
679#define Exp_11 0x3ff00000 -
680#define Ebits 11 -
681#define Frac_mask 0xfffff -
682#define Frac_mask1 0xfffff -
683#define Ten_pmax 22 -
684#define Bletch 0x10 -
685#define Bndry_mask 0xfffff -
686#define Bndry_mask1 0xfffff -
687#if defined(LSB) && defined(Q_OS_VXWORKS) -
688#undef LSB -
689#endif -
690#define LSB 1 -
691#define Sign_bit 0x80000000 -
692#define Log2P 1 -
693#define Tiny0 0 -
694#define Tiny1 1 -
695#define Quick_max 14 -
696#define Int_max 14 -
697#define Infinite(x) (getWord0(x) == 0x7ff00000) /* sufficient test for here */ -
698#else -
699#undef Sudden_Underflow -
700#define Sudden_Underflow -
701#ifdef IBM -
702#define Exp_shift 24 -
703#define Exp_shift1 24 -
704#define Exp_msk1 0x1000000 -
705#define Exp_msk11 0x1000000 -
706#define Exp_mask 0x7f000000 -
707#define P 14 -
708#define Bias 65 -
709#define Exp_1 0x41000000 -
710#define Exp_11 0x41000000 -
711#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ -
712#define Frac_mask 0xffffff -
713#define Frac_mask1 0xffffff -
714#define Bletch 4 -
715#define Ten_pmax 22 -
716#define Bndry_mask 0xefffff -
717#define Bndry_mask1 0xffffff -
718#define LSB 1 -
719#define Sign_bit 0x80000000 -
720#define Log2P 4 -
721#define Tiny0 0x100000 -
722#define Tiny1 0 -
723#define Quick_max 14 -
724#define Int_max 15 -
725#else /* VAX */ -
726#define Exp_shift 23 -
727#define Exp_shift1 7 -
728#define Exp_msk1 0x80 -
729#define Exp_msk11 0x800000 -
730#define Exp_mask 0x7f80 -
731#define P 56 -
732#define Bias 129 -
733#define Exp_1 0x40800000 -
734#define Exp_11 0x4080 -
735#define Ebits 8 -
736#define Frac_mask 0x7fffff -
737#define Frac_mask1 0xffff007f -
738#define Ten_pmax 24 -
739#define Bletch 2 -
740#define Bndry_mask 0xffff007f -
741#define Bndry_mask1 0xffff007f -
742#define LSB 0x10000 -
743#define Sign_bit 0x8000 -
744#define Log2P 1 -
745#define Tiny0 0x80 -
746#define Tiny1 0 -
747#define Quick_max 15 -
748#define Int_max 15 -
749#endif -
750#endif -
751 -
752#ifndef IEEE_Arith -
753#define ROUND_BIASED -
754#endif -
755 -
756#ifdef RND_PRODQUOT -
757#define rounded_product(a,b) a = rnd_prod(a, b) -
758#define rounded_quotient(a,b) a = rnd_quot(a, b) -
759extern double rnd_prod(double, double), rnd_quot(double, double); -
760#else -
761#define rounded_product(a,b) a *= b -
762#define rounded_quotient(a,b) a /= b -
763#endif -
764 -
765#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) -
766#define Big1 0xffffffff -
767 -
768#ifndef Just_16 -
769/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. -
770 * This makes some inner loops simpler and sometimes saves work -
771 * during multiplications, but it often seems to make things slightly -
772 * slower. Hence the default is now to store 32 bits per Long. -
773 */ -
774#ifndef Pack_32 -
775#define Pack_32 -
776#endif -
777#endif -
778 -
779#define Kmax 15 -
780 -
781struct -
782Bigint { -
783 struct Bigint *next; -
784 int k, maxwds, sign, wds; -
785 ULong x[1]; -
786}; -
787 -
788 typedef struct Bigint Bigint; -
789 -
790static Bigint *Balloc(int k) -
791{ -
792 int x;
executed (the execution status of this line is deduced): int x;
-
793 Bigint *rv;
executed (the execution status of this line is deduced): Bigint *rv;
-
794 -
795 x = 1 << k;
executed (the execution status of this line is deduced): x = 1 << k;
-
796 rv = static_cast<Bigint *>(MALLOC(sizeof(Bigint) + (x-1)*sizeof(Long)));
executed (the execution status of this line is deduced): rv = static_cast<Bigint *>(malloc(sizeof(Bigint) + (x-1)*sizeof(qint32)));
-
797 Q_CHECK_PTR(rv);
never executed: qBadAlloc();
executed: }
Execution Count:1476124
partially evaluated: !(rv)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1476124
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1476124
0-1476124
798 rv->k = k;
executed (the execution status of this line is deduced): rv->k = k;
-
799 rv->maxwds = x;
executed (the execution status of this line is deduced): rv->maxwds = x;
-
800 rv->sign = rv->wds = 0;
executed (the execution status of this line is deduced): rv->sign = rv->wds = 0;
-
801 return rv;
executed: return rv;
Execution Count:1476124
1476124
802} -
803 -
804static void Bfree(Bigint *v) -
805{ -
806 free(v);
executed (the execution status of this line is deduced): free(v);
-
807}
executed: }
Execution Count:1476126
1476126
808 -
809#define Bcopy(x,y) memcpy(reinterpret_cast<char *>(&x->sign), reinterpret_cast<char *>(&y->sign), \ -
810y->wds*sizeof(Long) + 2*sizeof(int)) -
811 -
812/* multiply by m and add a */ -
813static Bigint *multadd(Bigint *b, int m, int a) -
814{ -
815 int i, wds;
executed (the execution status of this line is deduced): int i, wds;
-
816 ULong *x, y;
executed (the execution status of this line is deduced): quint32 *x, y;
-
817#ifdef Pack_32 -
818 ULong xi, z;
executed (the execution status of this line is deduced): quint32 xi, z;
-
819#endif -
820 Bigint *b1;
executed (the execution status of this line is deduced): Bigint *b1;
-
821 -
822 wds = b->wds;
executed (the execution status of this line is deduced): wds = b->wds;
-
823 x = b->x;
executed (the execution status of this line is deduced): x = b->x;
-
824 i = 0;
executed (the execution status of this line is deduced): i = 0;
-
825 do { -
826#ifdef Pack_32 -
827 xi = *x;
executed (the execution status of this line is deduced): xi = *x;
-
828 y = (xi & 0xffff) * m + a;
executed (the execution status of this line is deduced): y = (xi & 0xffff) * m + a;
-
829 z = (xi >> 16) * m + (y >> 16);
executed (the execution status of this line is deduced): z = (xi >> 16) * m + (y >> 16);
-
830 a = (z >> 16);
executed (the execution status of this line is deduced): a = (z >> 16);
-
831 *x++ = (z << 16) + (y & 0xffff);
executed (the execution status of this line is deduced): *x++ = (z << 16) + (y & 0xffff);
-
832#else -
833 y = *x * m + a; -
834 a = (y >> 16); -
835 *x++ = y & 0xffff; -
836#endif -
837 }
executed: }
Execution Count:1276789
1276789
838 while(++i < wds);
evaluated: ++i < wds
TRUEFALSE
yes
Evaluation Count:1133800
yes
Evaluation Count:142989
142989-1133800
839 if (a) {
evaluated: a
TRUEFALSE
yes
Evaluation Count:2045
yes
Evaluation Count:140944
2045-140944
840 if (wds >= b->maxwds) {
partially evaluated: wds >= b->maxwds
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2045
0-2045
841 b1 = Balloc(b->k+1);
never executed (the execution status of this line is deduced): b1 = Balloc(b->k+1);
-
842 Bcopy(b1, b);
never executed (the execution status of this line is deduced): memcpy(reinterpret_cast<char *>(&b1->sign), reinterpret_cast<char *>(&b->sign), b->wds*sizeof(qint32) + 2*sizeof(int));
-
843 Bfree(b);
never executed (the execution status of this line is deduced): Bfree(b);
-
844 b = b1;
never executed (the execution status of this line is deduced): b = b1;
-
845 }
never executed: }
0
846 b->x[wds++] = a;
executed (the execution status of this line is deduced): b->x[wds++] = a;
-
847 b->wds = wds;
executed (the execution status of this line is deduced): b->wds = wds;
-
848 }
executed: }
Execution Count:2045
2045
849 return b;
executed: return b;
Execution Count:142989
142989
850} -
851 -
852static Bigint *s2b(const char *s, int nd0, int nd, ULong y9) -
853{ -
854 Bigint *b;
executed (the execution status of this line is deduced): Bigint *b;
-
855 int i, k;
executed (the execution status of this line is deduced): int i, k;
-
856 Long x, y;
executed (the execution status of this line is deduced): qint32 x, y;
-
857 -
858 x = (nd + 8) / 9;
executed (the execution status of this line is deduced): x = (nd + 8) / 9;
-
859 for(k = 0, y = 1; x > y; y <<= 1, k++) ;
executed: ;
Execution Count:517
evaluated: x > y
TRUEFALSE
yes
Evaluation Count:517
yes
Evaluation Count:161
161-517
860#ifdef Pack_32 -
861 b = Balloc(k);
executed (the execution status of this line is deduced): b = Balloc(k);
-
862 b->x[0] = y9;
executed (the execution status of this line is deduced): b->x[0] = y9;
-
863 b->wds = 1;
executed (the execution status of this line is deduced): b->wds = 1;
-
864#else -
865 b = Balloc(k+1); -
866 b->x[0] = y9 & 0xffff; -
867 b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; -
868#endif -
869 -
870 i = 9;
executed (the execution status of this line is deduced): i = 9;
-
871 if (9 < nd0) {
evaluated: 9 < nd0
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:32
32-129
872 s += 9;
executed (the execution status of this line is deduced): s += 9;
-
873 do b = multadd(b, 10, *s++ - '0');
executed: b = multadd(b, 10, *s++ - '0');
Execution Count:18442
18442
874 while(++i < nd0);
evaluated: ++i < nd0
TRUEFALSE
yes
Evaluation Count:18313
yes
Evaluation Count:129
129-18313
875 s++;
executed (the execution status of this line is deduced): s++;
-
876 }
executed: }
Execution Count:129
129
877 else -
878 s += 10;
executed: s += 10;
Execution Count:32
32
879 for(; i < nd; i++)
evaluated: i < nd
TRUEFALSE
yes
Evaluation Count:334
yes
Evaluation Count:161
161-334
880 b = multadd(b, 10, *s++ - '0');
executed: b = multadd(b, 10, *s++ - '0');
Execution Count:334
334
881 return b;
executed: return b;
Execution Count:161
161
882} -
883 -
884static int hi0bits(ULong x) -
885{ -
886 int k = 0;
executed (the execution status of this line is deduced): int k = 0;
-
887 -
888 if (!(x & 0xffff0000)) {
evaluated: !(x & 0xffff0000)
TRUEFALSE
yes
Evaluation Count:486
yes
Evaluation Count:411
411-486
889 k = 16;
executed (the execution status of this line is deduced): k = 16;
-
890 x <<= 16;
executed (the execution status of this line is deduced): x <<= 16;
-
891 }
executed: }
Execution Count:486
486
892 if (!(x & 0xff000000)) {
evaluated: !(x & 0xff000000)
TRUEFALSE
yes
Evaluation Count:395
yes
Evaluation Count:502
395-502
893 k += 8;
executed (the execution status of this line is deduced): k += 8;
-
894 x <<= 8;
executed (the execution status of this line is deduced): x <<= 8;
-
895 }
executed: }
Execution Count:395
395
896 if (!(x & 0xf0000000)) {
evaluated: !(x & 0xf0000000)
TRUEFALSE
yes
Evaluation Count:419
yes
Evaluation Count:478
419-478
897 k += 4;
executed (the execution status of this line is deduced): k += 4;
-
898 x <<= 4;
executed (the execution status of this line is deduced): x <<= 4;
-
899 }
executed: }
Execution Count:419
419
900 if (!(x & 0xc0000000)) {
evaluated: !(x & 0xc0000000)
TRUEFALSE
yes
Evaluation Count:527
yes
Evaluation Count:370
370-527
901 k += 2;
executed (the execution status of this line is deduced): k += 2;
-
902 x <<= 2;
executed (the execution status of this line is deduced): x <<= 2;
-
903 }
executed: }
Execution Count:527
527
904 if (!(x & 0x80000000)) {
evaluated: !(x & 0x80000000)
TRUEFALSE
yes
Evaluation Count:619
yes
Evaluation Count:278
278-619
905 k++;
executed (the execution status of this line is deduced): k++;
-
906 if (!(x & 0x40000000))
partially evaluated: !(x & 0x40000000)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:619
0-619
907 return 32;
never executed: return 32;
0
908 }
executed: }
Execution Count:619
619
909 return k;
executed: return k;
Execution Count:897
897
910} -
911 -
912static int lo0bits(ULong *y) -
913{ -
914 int k;
executed (the execution status of this line is deduced): int k;
-
915 ULong x = *y;
executed (the execution status of this line is deduced): quint32 x = *y;
-
916 -
917 if (x & 7) {
evaluated: x & 7
TRUEFALSE
yes
Evaluation Count:23206
yes
Evaluation Count:1440058
23206-1440058
918 if (x & 1)
evaluated: x & 1
TRUEFALSE
yes
Evaluation Count:10888
yes
Evaluation Count:12318
10888-12318
919 return 0;
executed: return 0;
Execution Count:10888
10888
920 if (x & 2) {
evaluated: x & 2
TRUEFALSE
yes
Evaluation Count:6418
yes
Evaluation Count:5900
5900-6418
921 *y = x >> 1;
executed (the execution status of this line is deduced): *y = x >> 1;
-
922 return 1;
executed: return 1;
Execution Count:6418
6418
923 } -
924 *y = x >> 2;
executed (the execution status of this line is deduced): *y = x >> 2;
-
925 return 2;
executed: return 2;
Execution Count:5900
5900
926 } -
927 k = 0;
executed (the execution status of this line is deduced): k = 0;
-
928 if (!(x & 0xffff)) {
evaluated: !(x & 0xffff)
TRUEFALSE
yes
Evaluation Count:717529
yes
Evaluation Count:722529
717529-722529
929 k = 16;
executed (the execution status of this line is deduced): k = 16;
-
930 x >>= 16;
executed (the execution status of this line is deduced): x >>= 16;
-
931 }
executed: }
Execution Count:717529
717529
932 if (!(x & 0xff)) {
evaluated: !(x & 0xff)
TRUEFALSE
yes
Evaluation Count:743001
yes
Evaluation Count:697057
697057-743001
933 k += 8;
executed (the execution status of this line is deduced): k += 8;
-
934 x >>= 8;
executed (the execution status of this line is deduced): x >>= 8;
-
935 }
executed: }
Execution Count:743001
743001
936 if (!(x & 0xf)) {
evaluated: !(x & 0xf)
TRUEFALSE
yes
Evaluation Count:874527
yes
Evaluation Count:565531
565531-874527
937 k += 4;
executed (the execution status of this line is deduced): k += 4;
-
938 x >>= 4;
executed (the execution status of this line is deduced): x >>= 4;
-
939 }
executed: }
Execution Count:874527
874527
940 if (!(x & 0x3)) {
evaluated: !(x & 0x3)
TRUEFALSE
yes
Evaluation Count:677243
yes
Evaluation Count:762815
677243-762815
941 k += 2;
executed (the execution status of this line is deduced): k += 2;
-
942 x >>= 2;
executed (the execution status of this line is deduced): x >>= 2;
-
943 }
executed: }
Execution Count:677243
677243
944 if (!(x & 1)) {
evaluated: !(x & 1)
TRUEFALSE
yes
Evaluation Count:675203
yes
Evaluation Count:764855
675203-764855
945 k++;
executed (the execution status of this line is deduced): k++;
-
946 x >>= 1;
executed (the execution status of this line is deduced): x >>= 1;
-
947 if (!x & 1)
partially evaluated: !x & 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:675203
0-675203
948 return 32;
never executed: return 32;
0
949 }
executed: }
Execution Count:675203
675203
950 *y = x;
executed (the execution status of this line is deduced): *y = x;
-
951 return k;
executed: return k;
Execution Count:1440058
1440058
952} -
953 -
954static Bigint *i2b(int i) -
955{ -
956 Bigint *b;
executed (the execution status of this line is deduced): Bigint *b;
-
957 -
958 b = Balloc(1);
executed (the execution status of this line is deduced): b = Balloc(1);
-
959 b->x[0] = i;
executed (the execution status of this line is deduced): b->x[0] = i;
-
960 b->wds = 1;
executed (the execution status of this line is deduced): b->wds = 1;
-
961 return b;
executed: return b;
Execution Count:2398
2398
962} -
963 -
964static Bigint *mult(Bigint *a, Bigint *b) -
965{ -
966 Bigint *c;
executed (the execution status of this line is deduced): Bigint *c;
-
967 int k, wa, wb, wc;
executed (the execution status of this line is deduced): int k, wa, wb, wc;
-
968 ULong carry, y, z;
executed (the execution status of this line is deduced): quint32 carry, y, z;
-
969 ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
executed (the execution status of this line is deduced): quint32 *x, *xa, *xae, *xb, *xbe, *xc, *xc0;
-
970#ifdef Pack_32 -
971 ULong z2;
executed (the execution status of this line is deduced): quint32 z2;
-
972#endif -
973 -
974 if (a->wds < b->wds) {
evaluated: a->wds < b->wds
TRUEFALSE
yes
Evaluation Count:1570
yes
Evaluation Count:1451
1451-1570
975 c = a;
executed (the execution status of this line is deduced): c = a;
-
976 a = b;
executed (the execution status of this line is deduced): a = b;
-
977 b = c;
executed (the execution status of this line is deduced): b = c;
-
978 }
executed: }
Execution Count:1570
1570
979 k = a->k;
executed (the execution status of this line is deduced): k = a->k;
-
980 wa = a->wds;
executed (the execution status of this line is deduced): wa = a->wds;
-
981 wb = b->wds;
executed (the execution status of this line is deduced): wb = b->wds;
-
982 wc = wa + wb;
executed (the execution status of this line is deduced): wc = wa + wb;
-
983 if (wc > a->maxwds)
evaluated: wc > a->maxwds
TRUEFALSE
yes
Evaluation Count:1619
yes
Evaluation Count:1402
1402-1619
984 k++;
executed: k++;
Execution Count:1619
1619
985 c = Balloc(k);
executed (the execution status of this line is deduced): c = Balloc(k);
-
986 for(x = c->x, xa = x + wc; x < xa; x++)
evaluated: x < xa
TRUEFALSE
yes
Evaluation Count:17702
yes
Evaluation Count:3021
3021-17702
987 *x = 0;
executed: *x = 0;
Execution Count:17702
17702
988 xa = a->x;
executed (the execution status of this line is deduced): xa = a->x;
-
989 xae = xa + wa;
executed (the execution status of this line is deduced): xae = xa + wa;
-
990 xb = b->x;
executed (the execution status of this line is deduced): xb = b->x;
-
991 xbe = xb + wb;
executed (the execution status of this line is deduced): xbe = xb + wb;
-
992 xc0 = c->x;
executed (the execution status of this line is deduced): xc0 = c->x;
-
993#ifdef Pack_32 -
994 for(; xb < xbe; xb++, xc0++) {
evaluated: xb < xbe
TRUEFALSE
yes
Evaluation Count:5645
yes
Evaluation Count:3021
3021-5645
995 if ((y = *xb & 0xffff) != 0) {
partially evaluated: (y = *xb & 0xffff) != 0
TRUEFALSE
yes
Evaluation Count:5645
no
Evaluation Count:0
0-5645
996 x = xa;
executed (the execution status of this line is deduced): x = xa;
-
997 xc = xc0;
executed (the execution status of this line is deduced): xc = xc0;
-
998 carry = 0;
executed (the execution status of this line is deduced): carry = 0;
-
999 do { -
1000 z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
executed (the execution status of this line is deduced): z = (*x & 0xffff) * y + (*xc & 0xffff) + carry;
-
1001 carry = z >> 16;
executed (the execution status of this line is deduced): carry = z >> 16;
-
1002 z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
executed (the execution status of this line is deduced): z2 = (*x++ >> 16) * y + (*xc >> 16) + carry;
-
1003 carry = z2 >> 16;
executed (the execution status of this line is deduced): carry = z2 >> 16;
-
1004 Storeinc(xc, z2, z);
executed (the execution status of this line is deduced): Storeinc(xc, z2, z);
-
1005 }
executed: }
Execution Count:36492
36492
1006 while(x < xae);
evaluated: x < xae
TRUEFALSE
yes
Evaluation Count:30847
yes
Evaluation Count:5645
5645-30847
1007 *xc = carry;
executed (the execution status of this line is deduced): *xc = carry;
-
1008 }
executed: }
Execution Count:5645
5645
1009 if ((y = *xb >> 16) != 0) {
evaluated: (y = *xb >> 16) != 0
TRUEFALSE
yes
Evaluation Count:3376
yes
Evaluation Count:2269
2269-3376
1010 x = xa;
executed (the execution status of this line is deduced): x = xa;
-
1011 xc = xc0;
executed (the execution status of this line is deduced): xc = xc0;
-
1012 carry = 0;
executed (the execution status of this line is deduced): carry = 0;
-
1013 z2 = *xc;
executed (the execution status of this line is deduced): z2 = *xc;
-
1014 do { -
1015 z = (*x & 0xffff) * y + (*xc >> 16) + carry;
executed (the execution status of this line is deduced): z = (*x & 0xffff) * y + (*xc >> 16) + carry;
-
1016 carry = z >> 16;
executed (the execution status of this line is deduced): carry = z >> 16;
-
1017 Storeinc(xc, z, z2);
executed (the execution status of this line is deduced): Storeinc(xc, z, z2);
-
1018 z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
executed (the execution status of this line is deduced): z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry;
-
1019 carry = z2 >> 16;
executed (the execution status of this line is deduced): carry = z2 >> 16;
-
1020 }
executed: }
Execution Count:30540
30540
1021 while(x < xae);
evaluated: x < xae
TRUEFALSE
yes
Evaluation Count:27164
yes
Evaluation Count:3376
3376-27164
1022 *xc = z2;
executed (the execution status of this line is deduced): *xc = z2;
-
1023 }
executed: }
Execution Count:3376
3376
1024 }
executed: }
Execution Count:5645
5645
1025#else -
1026 for(; xb < xbe; xc0++) { -
1027 if (y = *xb++) { -
1028 x = xa; -
1029 xc = xc0; -
1030 carry = 0; -
1031 do { -
1032 z = *x++ * y + *xc + carry; -
1033 carry = z >> 16; -
1034 *xc++ = z & 0xffff; -
1035 } -
1036 while(x < xae); -
1037 *xc = carry; -
1038 } -
1039 } -
1040#endif -
1041 for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ;
executed: ;
Execution Count:2160
partially evaluated: wc > 0
TRUEFALSE
yes
Evaluation Count:5181
no
Evaluation Count:0
evaluated: !*--xc
TRUEFALSE
yes
Evaluation Count:2160
yes
Evaluation Count:3021
0-5181
1042 c->wds = wc;
executed (the execution status of this line is deduced): c->wds = wc;
-
1043 return c;
executed: return c;
Execution Count:3021
3021
1044} -
1045 -
1046static Bigint *p5s; -
1047 -
1048struct p5s_deleter -
1049{ -
1050 ~p5s_deleter() -
1051 { -
1052 while (p5s) {
evaluated: p5s
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:5
5-29
1053 Bigint *next = p5s->next;
executed (the execution status of this line is deduced): Bigint *next = p5s->next;
-
1054 Bfree(p5s);
executed (the execution status of this line is deduced): Bfree(p5s);
-
1055 p5s = next;
executed (the execution status of this line is deduced): p5s = next;
-
1056 }
executed: }
Execution Count:29
29
1057 }
executed: }
Execution Count:5
5
1058}; -
1059 -
1060static Bigint *pow5mult(Bigint *b, int k) -
1061{ -
1062 Bigint *b1, *p5, *p51;
executed (the execution status of this line is deduced): Bigint *b1, *p5, *p51;
-
1063 int i;
executed (the execution status of this line is deduced): int i;
-
1064 static const int p05[3] = { 5, 25, 125 }; -
1065 -
1066 if ((i = k & 3) != 0)
evaluated: (i = k & 3) != 0
TRUEFALSE
yes
Evaluation Count:1487
yes
Evaluation Count:395
395-1487
1067#if defined(Q_OS_IRIX) && defined(Q_CC_GNU) -
1068 { -
1069 // work around a bug on 64 bit IRIX gcc -
1070 int *p = (int *) p05; -
1071 b = multadd(b, p[i-1], 0); -
1072 } -
1073#else -
1074 b = multadd(b, p05[i-1], 0);
executed: b = multadd(b, p05[i-1], 0);
Execution Count:1487
1487
1075#endif -
1076 -
1077 if (!(k >>= 2))
evaluated: !(k >>= 2)
TRUEFALSE
yes
Evaluation Count:622
yes
Evaluation Count:1260
622-1260
1078 return b;
executed: return b;
Execution Count:622
622
1079 if (!(p5 = p5s)) {
evaluated: !(p5 = p5s)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1255
5-1255
1080 /* first time */ -
1081 static p5s_deleter deleter; -
1082 p5 = p5s = i2b(625);
executed (the execution status of this line is deduced): p5 = p5s = i2b(625);
-
1083 p5->next = 0;
executed (the execution status of this line is deduced): p5->next = 0;
-
1084 }
executed: }
Execution Count:5
5
1085 for(;;) {
executed (the execution status of this line is deduced): for(;;) {
-
1086 if (k & 1) {
evaluated: k & 1
TRUEFALSE
yes
Evaluation Count:2910
yes
Evaluation Count:2376
2376-2910
1087 b1 = mult(b, p5);
executed (the execution status of this line is deduced): b1 = mult(b, p5);
-
1088 Bfree(b);
executed (the execution status of this line is deduced): Bfree(b);
-
1089 b = b1;
executed (the execution status of this line is deduced): b = b1;
-
1090 }
executed: }
Execution Count:2910
2910
1091 if (!(k >>= 1))
evaluated: !(k >>= 1)
TRUEFALSE
yes
Evaluation Count:1260
yes
Evaluation Count:4026
1260-4026
1092 break;
executed: break;
Execution Count:1260
1260
1093 if (!(p51 = p5->next)) {
evaluated: !(p51 = p5->next)
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:4002
24-4002
1094 p51 = p5->next = mult(p5,p5);
executed (the execution status of this line is deduced): p51 = p5->next = mult(p5,p5);
-
1095 p51->next = 0;
executed (the execution status of this line is deduced): p51->next = 0;
-
1096 }
executed: }
Execution Count:24
24
1097 p5 = p51;
executed (the execution status of this line is deduced): p5 = p51;
-
1098 }
executed: }
Execution Count:4026
4026
1099 return b;
executed: return b;
Execution Count:1260
1260
1100} -
1101 -
1102static Bigint *lshift(Bigint *b, int k) -
1103{ -
1104 int i, k1, n, n1;
executed (the execution status of this line is deduced): int i, k1, n, n1;
-
1105 Bigint *b1;
executed (the execution status of this line is deduced): Bigint *b1;
-
1106 ULong *x, *x1, *xe, z;
executed (the execution status of this line is deduced): quint32 *x, *x1, *xe, z;
-
1107 -
1108#ifdef Pack_32 -
1109 n = k >> 5;
executed (the execution status of this line is deduced): n = k >> 5;
-
1110#else -
1111 n = k >> 4; -
1112#endif -
1113 k1 = b->k;
executed (the execution status of this line is deduced): k1 = b->k;
-
1114 n1 = n + b->wds + 1;
executed (the execution status of this line is deduced): n1 = n + b->wds + 1;
-
1115 for(i = b->maxwds; n1 > i; i <<= 1)
evaluated: n1 > i
TRUEFALSE
yes
Evaluation Count:5466
yes
Evaluation Count:6954
5466-6954
1116 k1++;
executed: k1++;
Execution Count:5466
5466
1117 b1 = Balloc(k1);
executed (the execution status of this line is deduced): b1 = Balloc(k1);
-
1118 x1 = b1->x;
executed (the execution status of this line is deduced): x1 = b1->x;
-
1119 for(i = 0; i < n; i++)
evaluated: i < n
TRUEFALSE
yes
Evaluation Count:13897
yes
Evaluation Count:6954
6954-13897
1120 *x1++ = 0;
executed: *x1++ = 0;
Execution Count:13897
13897
1121 x = b->x;
executed (the execution status of this line is deduced): x = b->x;
-
1122 xe = x + b->wds;
executed (the execution status of this line is deduced): xe = x + b->wds;
-
1123#ifdef Pack_32 -
1124 if (k &= 0x1f) {
evaluated: k &= 0x1f
TRUEFALSE
yes
Evaluation Count:6945
yes
Evaluation Count:9
9-6945
1125 k1 = 32 - k;
executed (the execution status of this line is deduced): k1 = 32 - k;
-
1126 z = 0;
executed (the execution status of this line is deduced): z = 0;
-
1127 do { -
1128 *x1++ = *x << k | z;
executed (the execution status of this line is deduced): *x1++ = *x << k | z;
-
1129 z = *x++ >> k1;
executed (the execution status of this line is deduced): z = *x++ >> k1;
-
1130 }
executed: }
Execution Count:26454
26454
1131 while(x < xe);
evaluated: x < xe
TRUEFALSE
yes
Evaluation Count:19509
yes
Evaluation Count:6945
6945-19509
1132 if ((*x1 = z) != 0)
evaluated: (*x1 = z) != 0
TRUEFALSE
yes
Evaluation Count:114
yes
Evaluation Count:6831
114-6831
1133 ++n1;
executed: ++n1;
Execution Count:114
114
1134 }
executed: }
Execution Count:6945
6945
1135#else -
1136 if (k &= 0xf) { -
1137 k1 = 16 - k; -
1138 z = 0; -
1139 do { -
1140 *x1++ = *x << k & 0xffff | z; -
1141 z = *x++ >> k1; -
1142 } -
1143 while(x < xe); -
1144 if (*x1 = z) -
1145 ++n1; -
1146 } -
1147#endif -
1148 else do -
1149 *x1++ = *x++;
executed: *x1++ = *x++;
Execution Count:26
26
1150 while(x < xe);
evaluated: x < xe
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:9
9-17
1151 b1->wds = n1 - 1;
executed (the execution status of this line is deduced): b1->wds = n1 - 1;
-
1152 Bfree(b);
executed (the execution status of this line is deduced): Bfree(b);
-
1153 return b1;
executed: return b1;
Execution Count:6954
6954
1154} -
1155 -
1156static int cmp(Bigint *a, Bigint *b) -
1157{ -
1158 ULong *xa, *xa0, *xb, *xb0;
executed (the execution status of this line is deduced): quint32 *xa, *xa0, *xb, *xb0;
-
1159 int i, j;
executed (the execution status of this line is deduced): int i, j;
-
1160 -
1161 i = a->wds;
executed (the execution status of this line is deduced): i = a->wds;
-
1162 j = b->wds;
executed (the execution status of this line is deduced): j = b->wds;
-
1163#ifdef BSD_QDTOA_DEBUG -
1164 if (i > 1 && !a->x[i-1]) -
1165 Bug("cmp called with a->x[a->wds-1] == 0"); -
1166 if (j > 1 && !b->x[j-1]) -
1167 Bug("cmp called with b->x[b->wds-1] == 0"); -
1168#endif -
1169 if (i -= j)
evaluated: i -= j
TRUEFALSE
yes
Evaluation Count:538
yes
Evaluation Count:124147
538-124147
1170 return i;
executed: return i;
Execution Count:538
538
1171 xa0 = a->x;
executed (the execution status of this line is deduced): xa0 = a->x;
-
1172 xa = xa0 + j;
executed (the execution status of this line is deduced): xa = xa0 + j;
-
1173 xb0 = b->x;
executed (the execution status of this line is deduced): xb0 = b->x;
-
1174 xb = xb0 + j;
executed (the execution status of this line is deduced): xb = xb0 + j;
-
1175 for(;;) {
executed (the execution status of this line is deduced): for(;;) {
-
1176 if (*--xa != *--xb)
evaluated: *--xa != *--xb
TRUEFALSE
yes
Evaluation Count:123564
yes
Evaluation Count:4221
4221-123564
1177 return *xa < *xb ? -1 : 1;
executed: return *xa < *xb ? -1 : 1;
Execution Count:123564
123564
1178 if (xa <= xa0)
evaluated: xa <= xa0
TRUEFALSE
yes
Evaluation Count:583
yes
Evaluation Count:3638
583-3638
1179 break;
executed: break;
Execution Count:583
583
1180 }
executed: }
Execution Count:3638
3638
1181 return 0;
executed: return 0;
Execution Count:583
583
1182} -
1183 -
1184static Bigint *diff(Bigint *a, Bigint *b) -
1185{ -
1186 Bigint *c;
executed (the execution status of this line is deduced): Bigint *c;
-
1187 int i, wa, wb;
executed (the execution status of this line is deduced): int i, wa, wb;
-
1188 Long borrow, y; /* We need signed shifts here. */
executed (the execution status of this line is deduced): qint32 borrow, y;
-
1189 ULong *xa, *xae, *xb, *xbe, *xc;
executed (the execution status of this line is deduced): quint32 *xa, *xae, *xb, *xbe, *xc;
-
1190#ifdef Pack_32 -
1191 Long z;
executed (the execution status of this line is deduced): qint32 z;
-
1192#endif -
1193 -
1194 i = cmp(a,b);
executed (the execution status of this line is deduced): i = cmp(a,b);
-
1195 if (!i) {
evaluated: !i
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:161
2-161
1196 c = Balloc(0);
executed (the execution status of this line is deduced): c = Balloc(0);
-
1197 c->wds = 1;
executed (the execution status of this line is deduced): c->wds = 1;
-
1198 c->x[0] = 0;
executed (the execution status of this line is deduced): c->x[0] = 0;
-
1199 return c;
executed: return c;
Execution Count:2
2
1200 } -
1201 if (i < 0) {
evaluated: i < 0
TRUEFALSE
yes
Evaluation Count:139
yes
Evaluation Count:22
22-139
1202 c = a;
executed (the execution status of this line is deduced): c = a;
-
1203 a = b;
executed (the execution status of this line is deduced): a = b;
-
1204 b = c;
executed (the execution status of this line is deduced): b = c;
-
1205 i = 1;
executed (the execution status of this line is deduced): i = 1;
-
1206 }
executed: }
Execution Count:139
139
1207 else -
1208 i = 0;
executed: i = 0;
Execution Count:22
22
1209 c = Balloc(a->k);
executed (the execution status of this line is deduced): c = Balloc(a->k);
-
1210 c->sign = i;
executed (the execution status of this line is deduced): c->sign = i;
-
1211 wa = a->wds;
executed (the execution status of this line is deduced): wa = a->wds;
-
1212 xa = a->x;
executed (the execution status of this line is deduced): xa = a->x;
-
1213 xae = xa + wa;
executed (the execution status of this line is deduced): xae = xa + wa;
-
1214 wb = b->wds;
executed (the execution status of this line is deduced): wb = b->wds;
-
1215 xb = b->x;
executed (the execution status of this line is deduced): xb = b->x;
-
1216 xbe = xb + wb;
executed (the execution status of this line is deduced): xbe = xb + wb;
-
1217 xc = c->x;
executed (the execution status of this line is deduced): xc = c->x;
-
1218 borrow = 0;
executed (the execution status of this line is deduced): borrow = 0;
-
1219#ifdef Pack_32 -
1220 do { -
1221 y = (*xa & 0xffff) - (*xb & 0xffff) + borrow;
executed (the execution status of this line is deduced): y = (*xa & 0xffff) - (*xb & 0xffff) + borrow;
-
1222 borrow = y >> 16;
executed (the execution status of this line is deduced): borrow = y >> 16;
-
1223 Sign_Extend(borrow, y); -
1224 z = (*xa++ >> 16) - (*xb++ >> 16) + borrow;
executed (the execution status of this line is deduced): z = (*xa++ >> 16) - (*xb++ >> 16) + borrow;
-
1225 borrow = z >> 16;
executed (the execution status of this line is deduced): borrow = z >> 16;
-
1226 Sign_Extend(borrow, z); -
1227 Storeinc(xc, z, y);
executed (the execution status of this line is deduced): Storeinc(xc, z, y);
-
1228 }
executed: }
Execution Count:2417
2417
1229 while(xb < xbe);
evaluated: xb < xbe
TRUEFALSE
yes
Evaluation Count:2256
yes
Evaluation Count:161
161-2256
1230 while(xa < xae) {
partially evaluated: xa < xae
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:161
0-161
1231 y = (*xa & 0xffff) + borrow;
never executed (the execution status of this line is deduced): y = (*xa & 0xffff) + borrow;
-
1232 borrow = y >> 16;
never executed (the execution status of this line is deduced): borrow = y >> 16;
-
1233 Sign_Extend(borrow, y); -
1234 z = (*xa++ >> 16) + borrow;
never executed (the execution status of this line is deduced): z = (*xa++ >> 16) + borrow;
-
1235 borrow = z >> 16;
never executed (the execution status of this line is deduced): borrow = z >> 16;
-
1236 Sign_Extend(borrow, z); -
1237 Storeinc(xc, z, y);
never executed (the execution status of this line is deduced): Storeinc(xc, z, y);
-
1238 }
never executed: }
0
1239#else -
1240 do { -
1241 y = *xa++ - *xb++ + borrow; -
1242 borrow = y >> 16; -
1243 Sign_Extend(borrow, y); -
1244 *xc++ = y & 0xffff; -
1245 } -
1246 while(xb < xbe); -
1247 while(xa < xae) { -
1248 y = *xa++ + borrow; -
1249 borrow = y >> 16; -
1250 Sign_Extend(borrow, y); -
1251 *xc++ = y & 0xffff; -
1252 } -
1253#endif -
1254 while(!*--xc)
evaluated: !*--xc
TRUEFALSE
yes
Evaluation Count:240
yes
Evaluation Count:161
161-240
1255 wa--;
executed: wa--;
Execution Count:240
240
1256 c->wds = wa;
executed (the execution status of this line is deduced): c->wds = wa;
-
1257 return c;
executed: return c;
Execution Count:161
161
1258} -
1259 -
1260static double ulp(double x) -
1261{ -
1262 Long L;
executed (the execution status of this line is deduced): qint32 L;
-
1263 double a;
executed (the execution status of this line is deduced): double a;
-
1264 -
1265 L = (getWord0(x) & Exp_mask) - (P-1)*Exp_msk1;
executed (the execution status of this line is deduced): L = (getWord0(x) & 0x7ff00000) - (53 -1)*0x100000;
-
1266#ifndef Sudden_Underflow -
1267 if (L > 0) {
partially evaluated: L > 0
TRUEFALSE
yes
Evaluation Count:133
no
Evaluation Count:0
0-133
1268#endif -
1269#ifdef IBM -
1270 L |= Exp_msk1 >> 4; -
1271#endif -
1272 setWord0(&a, L);
executed (the execution status of this line is deduced): setWord0(&a, L);
-
1273 setWord1(&a, 0);
executed (the execution status of this line is deduced): setWord1(&a, 0);
-
1274#ifndef Sudden_Underflow -
1275 }
executed: }
Execution Count:133
133
1276 else { -
1277 L = -L >> Exp_shift;
never executed (the execution status of this line is deduced): L = -L >> 20;
-
1278 if (L < Exp_shift) {
never evaluated: L < 20
0
1279 setWord0(&a, 0x80000 >> L);
never executed (the execution status of this line is deduced): setWord0(&a, 0x80000 >> L);
-
1280 setWord1(&a, 0);
never executed (the execution status of this line is deduced): setWord1(&a, 0);
-
1281 }
never executed: }
0
1282 else { -
1283 setWord0(&a, 0);
never executed (the execution status of this line is deduced): setWord0(&a, 0);
-
1284 L -= Exp_shift;
never executed (the execution status of this line is deduced): L -= 20;
-
1285 setWord1(&a, L >= 31 ? 1U : 1U << (31 - L));
never executed (the execution status of this line is deduced): setWord1(&a, L >= 31 ? 1U : 1U << (31 - L));
-
1286 }
never executed: }
0
1287 } -
1288#endif -
1289 return a;
executed: return a;
Execution Count:133
133
1290} -
1291 -
1292static double b2d(Bigint *a, int *e) -
1293{ -
1294 ULong *xa, *xa0, w, y, z;
executed (the execution status of this line is deduced): quint32 *xa, *xa0, w, y, z;
-
1295 int k;
executed (the execution status of this line is deduced): int k;
-
1296 double d;
executed (the execution status of this line is deduced): double d;
-
1297 -
1298 xa0 = a->x;
executed (the execution status of this line is deduced): xa0 = a->x;
-
1299 xa = xa0 + a->wds;
executed (the execution status of this line is deduced): xa = xa0 + a->wds;
-
1300 y = *--xa;
executed (the execution status of this line is deduced): y = *--xa;
-
1301#ifdef BSD_QDTOA_DEBUG -
1302 if (!y) Bug("zero y in b2d"); -
1303#endif -
1304 k = hi0bits(y);
executed (the execution status of this line is deduced): k = hi0bits(y);
-
1305 *e = 32 - k;
executed (the execution status of this line is deduced): *e = 32 - k;
-
1306#ifdef Pack_32 -
1307 if (k < Ebits) {
evaluated: k < 11
TRUEFALSE
yes
Evaluation Count:60
yes
Evaluation Count:206
60-206
1308 setWord0(&d, Exp_1 | y >> (Ebits - k));
executed (the execution status of this line is deduced): setWord0(&d, 0x3ff00000 | y >> (11 - k));
-
1309 w = xa > xa0 ? *--xa : 0;
partially evaluated: xa > xa0
TRUEFALSE
yes
Evaluation Count:60
no
Evaluation Count:0
0-60
1310 setWord1(&d, y << ((32-Ebits) + k) | w >> (Ebits - k));
executed (the execution status of this line is deduced): setWord1(&d, y << ((32-11) + k) | w >> (11 - k));
-
1311 goto ret_d;
executed: goto ret_d;
Execution Count:60
60
1312 } -
1313 z = xa > xa0 ? *--xa : 0;
evaluated: xa > xa0
TRUEFALSE
yes
Evaluation Count:204
yes
Evaluation Count:2
2-204
1314 if (k -= Ebits) {
evaluated: k -= 11
TRUEFALSE
yes
Evaluation Count:202
yes
Evaluation Count:4
4-202
1315 setWord0(&d, Exp_1 | y << k | z >> (32 - k));
executed (the execution status of this line is deduced): setWord0(&d, 0x3ff00000 | y << k | z >> (32 - k));
-
1316 y = xa > xa0 ? *--xa : 0;
evaluated: xa > xa0
TRUEFALSE
yes
Evaluation Count:155
yes
Evaluation Count:47
47-155
1317 setWord1(&d, z << k | y >> (32 - k));
executed (the execution status of this line is deduced): setWord1(&d, z << k | y >> (32 - k));
-
1318 }
executed: }
Execution Count:202
202
1319 else { -
1320 setWord0(&d, Exp_1 | y);
executed (the execution status of this line is deduced): setWord0(&d, 0x3ff00000 | y);
-
1321 setWord1(&d, z);
executed (the execution status of this line is deduced): setWord1(&d, z);
-
1322 }
executed: }
Execution Count:4
4
1323#else -
1324 if (k < Ebits + 16) { -
1325 z = xa > xa0 ? *--xa : 0; -
1326 setWord0(&d, Exp_1 | y << k - Ebits | z >> Ebits + 16 - k); -
1327 w = xa > xa0 ? *--xa : 0; -
1328 y = xa > xa0 ? *--xa : 0; -
1329 setWord1(&d, z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k); -
1330 goto ret_d; -
1331 } -
1332 z = xa > xa0 ? *--xa : 0; -
1333 w = xa > xa0 ? *--xa : 0; -
1334 k -= Ebits + 16; -
1335 setWord0(&d, Exp_1 | y << k + 16 | z << k | w >> 16 - k); -
1336 y = xa > xa0 ? *--xa : 0; -
1337 setWord1(&d, w << k + 16 | y << k); -
1338#endif -
1339 ret_d: -
1340 return d;
executed: return d;
Execution Count:266
266
1341} -
1342 -
1343static Bigint *d2b(double d, int *e, int *bits) -
1344{ -
1345 Bigint *b;
executed (the execution status of this line is deduced): Bigint *b;
-
1346 int de, i, k;
executed (the execution status of this line is deduced): int de, i, k;
-
1347 ULong *x, y, z;
executed (the execution status of this line is deduced): quint32 *x, y, z;
-
1348 -
1349#ifdef Pack_32 -
1350 b = Balloc(1);
executed (the execution status of this line is deduced): b = Balloc(1);
-
1351#else -
1352 b = Balloc(2); -
1353#endif -
1354 x = b->x;
executed (the execution status of this line is deduced): x = b->x;
-
1355 -
1356 z = getWord0(d) & Frac_mask;
executed (the execution status of this line is deduced): z = getWord0(d) & 0xfffff;
-
1357 setWord0(&d, getWord0(d) & 0x7fffffff); /* clear sign bit, which we ignore */
executed (the execution status of this line is deduced): setWord0(&d, getWord0(d) & 0x7fffffff);
-
1358#ifdef Sudden_Underflow -
1359 de = (int)(getWord0(d) >> Exp_shift); -
1360#ifndef IBM -
1361 z |= Exp_msk11; -
1362#endif -
1363#else -
1364 if ((de = int(getWord0(d) >> Exp_shift)) != 0)
evaluated: (de = int(getWord0(d) >> 20)) != 0
TRUEFALSE
yes
Evaluation Count:1463252
yes
Evaluation Count:12
12-1463252
1365 z |= Exp_msk1;
executed: z |= 0x100000;
Execution Count:1463252
1463252
1366#endif -
1367#ifdef Pack_32 -
1368 if ((y = getWord1(d)) != 0) {
evaluated: (y = getWord1(d)) != 0
TRUEFALSE
yes
Evaluation Count:109936
yes
Evaluation Count:1353328
109936-1353328
1369 if ((k = lo0bits(&y)) != 0) {
evaluated: (k = lo0bits(&y)) != 0
TRUEFALSE
yes
Evaluation Count:103173
yes
Evaluation Count:6763
6763-103173
1370 x[0] = y | z << (32 - k);
executed (the execution status of this line is deduced): x[0] = y | z << (32 - k);
-
1371 z >>= k;
executed (the execution status of this line is deduced): z >>= k;
-
1372 }
executed: }
Execution Count:103173
103173
1373 else -
1374 x[0] = y;
executed: x[0] = y;
Execution Count:6763
6763
1375 i = b->wds = (x[1] = z) ? 2 : 1;
evaluated: (x[1] = z)
TRUEFALSE
yes
Evaluation Count:13398
yes
Evaluation Count:96538
13398-96538
1376 }
executed: }
Execution Count:109936
109936
1377 else { -
1378#ifdef BSD_QDTOA_DEBUG -
1379 if (!z) -
1380 Bug("Zero passed to d2b"); -
1381#endif -
1382 k = lo0bits(&z);
executed (the execution status of this line is deduced): k = lo0bits(&z);
-
1383 x[0] = z;
executed (the execution status of this line is deduced): x[0] = z;
-
1384 i = b->wds = 1;
executed (the execution status of this line is deduced): i = b->wds = 1;
-
1385 k += 32;
executed (the execution status of this line is deduced): k += 32;
-
1386 }
executed: }
Execution Count:1353328
1353328
1387#else -
1388 if (y = getWord1(d)) { -
1389 if (k = lo0bits(&y)) -
1390 if (k >= 16) { -
1391 x[0] = y | z << 32 - k & 0xffff; -
1392 x[1] = z >> k - 16 & 0xffff; -
1393 x[2] = z >> k; -
1394 i = 2; -
1395 } -
1396 else { -
1397 x[0] = y & 0xffff; -
1398 x[1] = y >> 16 | z << 16 - k & 0xffff; -
1399 x[2] = z >> k & 0xffff; -
1400 x[3] = z >> k+16; -
1401 i = 3; -
1402 } -
1403 else { -
1404 x[0] = y & 0xffff; -
1405 x[1] = y >> 16; -
1406 x[2] = z & 0xffff; -
1407 x[3] = z >> 16; -
1408 i = 3; -
1409 } -
1410 } -
1411 else { -
1412#ifdef BSD_QDTOA_DEBUG -
1413 if (!z) -
1414 Bug("Zero passed to d2b"); -
1415#endif -
1416 k = lo0bits(&z); -
1417 if (k >= 16) { -
1418 x[0] = z; -
1419 i = 0; -
1420 } -
1421 else { -
1422 x[0] = z & 0xffff; -
1423 x[1] = z >> 16; -
1424 i = 1; -
1425 } -
1426 k += 32; -
1427 } -
1428 while(!x[i]) -
1429 --i; -
1430 b->wds = i + 1; -
1431#endif -
1432#ifndef Sudden_Underflow -
1433 if (de) {
evaluated: de
TRUEFALSE
yes
Evaluation Count:1463252
yes
Evaluation Count:12
12-1463252
1434#endif -
1435#ifdef IBM -
1436 *e = (de - Bias - (P-1) << 2) + k; -
1437 *bits = 4*P + 8 - k - hi0bits(getWord0(d) & Frac_mask); -
1438#else -
1439 *e = de - Bias - (P-1) + k;
executed (the execution status of this line is deduced): *e = de - 1023 - (53 -1) + k;
-
1440 *bits = P - k;
executed (the execution status of this line is deduced): *bits = 53 - k;
-
1441#endif -
1442#ifndef Sudden_Underflow -
1443 }
executed: }
Execution Count:1463252
1463252
1444 else { -
1445 *e = de - Bias - (P-1) + 1 + k;
executed (the execution status of this line is deduced): *e = de - 1023 - (53 -1) + 1 + k;
-
1446#ifdef Pack_32 -
1447 *bits = 32*i - hi0bits(x[i-1]);
executed (the execution status of this line is deduced): *bits = 32*i - hi0bits(x[i-1]);
-
1448#else -
1449 *bits = (i+2)*16 - hi0bits(x[i]); -
1450#endif -
1451 }
executed: }
Execution Count:12
12
1452#endif -
1453 return b;
executed: return b;
Execution Count:1463264
1463264
1454} -
1455 -
1456static double ratio(Bigint *a, Bigint *b) -
1457{ -
1458 double da, db;
executed (the execution status of this line is deduced): double da, db;
-
1459 int k, ka, kb;
executed (the execution status of this line is deduced): int k, ka, kb;
-
1460 -
1461 da = b2d(a, &ka);
executed (the execution status of this line is deduced): da = b2d(a, &ka);
-
1462 db = b2d(b, &kb);
executed (the execution status of this line is deduced): db = b2d(b, &kb);
-
1463#ifdef Pack_32 -
1464 k = ka - kb + 32*(a->wds - b->wds);
executed (the execution status of this line is deduced): k = ka - kb + 32*(a->wds - b->wds);
-
1465#else -
1466 k = ka - kb + 16*(a->wds - b->wds); -
1467#endif -
1468#ifdef IBM -
1469 if (k > 0) { -
1470 setWord0(&da, getWord0(da) + (k >> 2)*Exp_msk1); -
1471 if (k &= 3) -
1472 da *= 1 << k; -
1473 } -
1474 else { -
1475 k = -k; -
1476 setWord0(&db, getWord0(db) + (k >> 2)*Exp_msk1); -
1477 if (k &= 3) -
1478 db *= 1 << k; -
1479 } -
1480#else -
1481 if (k > 0)
evaluated: k > 0
TRUEFALSE
yes
Evaluation Count:125
yes
Evaluation Count:8
8-125
1482 setWord0(&da, getWord0(da) + k*Exp_msk1);
executed: setWord0(&da, getWord0(da) + k*0x100000);
Execution Count:125
125
1483 else { -
1484 k = -k;
executed (the execution status of this line is deduced): k = -k;
-
1485 setWord0(&db, getWord0(db) + k*Exp_msk1);
executed (the execution status of this line is deduced): setWord0(&db, getWord0(db) + k*0x100000);
-
1486 }
executed: }
Execution Count:8
8
1487#endif -
1488 return da / db;
executed: return da / db;
Execution Count:133
133
1489} -
1490 -
1491static const double tens[] = { -
1492 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, -
1493 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, -
1494 1e20, 1e21, 1e22 -
1495#ifdef VAX -
1496 , 1e23, 1e24 -
1497#endif -
1498}; -
1499 -
1500#ifdef IEEE_Arith -
1501static const double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; -
1502static const double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 }; -
1503#define n_bigtens 5 -
1504#else -
1505#ifdef IBM -
1506static const double bigtens[] = { 1e16, 1e32, 1e64 }; -
1507static const double tinytens[] = { 1e-16, 1e-32, 1e-64 }; -
1508#define n_bigtens 3 -
1509#else -
1510static const double bigtens[] = { 1e16, 1e32 }; -
1511static const double tinytens[] = { 1e-16, 1e-32 }; -
1512#define n_bigtens 2 -
1513#endif -
1514#endif -
1515 -
1516/* -
1517 The pre-release gcc3.3 shipped with SuSE 8.2 has a bug which causes -
1518 the comparison 1e-100 == 0.0 to return true. As a workaround, we -
1519 compare it to a global variable containing 0.0, which produces -
1520 correct assembler output. -
1521 -
1522 ### consider detecting the broken compilers and using the static -
1523 ### double for these, and use a #define for all working compilers -
1524*/ -
1525static double g_double_zero = 0.0; -
1526 -
1527Q_CORE_EXPORT double qstrtod(const char *s00, const char **se, bool *ok) -
1528{ -
1529 int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
executed (the execution status of this line is deduced): int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign,
-
1530 e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
executed (the execution status of this line is deduced): e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign;
-
1531 const char *s, *s0, *s1;
executed (the execution status of this line is deduced): const char *s, *s0, *s1;
-
1532 double aadj, aadj1, adj, rv, rv0;
executed (the execution status of this line is deduced): double aadj, aadj1, adj, rv, rv0;
-
1533 Long L;
executed (the execution status of this line is deduced): qint32 L;
-
1534 ULong y, z;
executed (the execution status of this line is deduced): quint32 y, z;
-
1535 Bigint *bb1, *bd0;
executed (the execution status of this line is deduced): Bigint *bb1, *bd0;
-
1536 Bigint *bb = NULL, *bd = NULL, *bs = NULL, *delta = NULL;/* pacify gcc */
executed (the execution status of this line is deduced): Bigint *bb = __null, *bd = __null, *bs = __null, *delta = __null;
-
1537 -
1538 /* -
1539 #ifndef KR_headers -
1540 const char decimal_point = localeconv()->decimal_point[0]; -
1541 #else -
1542 const char decimal_point = '.'; -
1543 #endif */ -
1544 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:4149
no
Evaluation Count:0
0-4149
1545 *ok = true;
executed: *ok = true;
Execution Count:4149
4149
1546 -
1547 const char decimal_point = '.';
executed (the execution status of this line is deduced): const char decimal_point = '.';
-
1548 -
1549 sign = nz0 = nz = 0;
executed (the execution status of this line is deduced): sign = nz0 = nz = 0;
-
1550 rv = 0.;
executed (the execution status of this line is deduced): rv = 0.;
-
1551 -
1552 -
1553 for(s = s00; isspace(uchar(*s)); s++)
partially evaluated: isspace(uchar(*s))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4149
0-4149
1554 ;
never executed: ;
0
1555 -
1556 if (*s == '-') {
evaluated: *s == '-'
TRUEFALSE
yes
Evaluation Count:411
yes
Evaluation Count:3738
411-3738
1557 sign = 1;
executed (the execution status of this line is deduced): sign = 1;
-
1558 s++;
executed (the execution status of this line is deduced): s++;
-
1559 } else if (*s == '+') {
executed: }
Execution Count:411
evaluated: *s == '+'
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:3731
7-3731
1560 s++;
executed (the execution status of this line is deduced): s++;
-
1561 }
executed: }
Execution Count:7
7
1562 -
1563 if (*s == '\0') {
evaluated: *s == '\0'
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:4141
8-4141
1564 s = s00;
executed (the execution status of this line is deduced): s = s00;
-
1565 goto ret;
executed: goto ret;
Execution Count:8
8
1566 } -
1567 -
1568 if (*s == '0') {
evaluated: *s == '0'
TRUEFALSE
yes
Evaluation Count:1529
yes
Evaluation Count:2612
1529-2612
1569 nz0 = 1;
executed (the execution status of this line is deduced): nz0 = 1;
-
1570 while(*++s == '0') ;
executed: ;
Execution Count:81
evaluated: *++s == '0'
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:1529
81-1529
1571 if (!*s)
evaluated: !*s
TRUEFALSE
yes
Evaluation Count:739
yes
Evaluation Count:790
739-790
1572 goto ret;
executed: goto ret;
Execution Count:739
739
1573 }
executed: }
Execution Count:790
790
1574 s0 = s;
executed (the execution status of this line is deduced): s0 = s;
-
1575 y = z = 0;
executed (the execution status of this line is deduced): y = z = 0;
-
1576 for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++)
evaluated: (c = *s) >= '0'
TRUEFALSE
yes
Evaluation Count:26429
yes
Evaluation Count:3065
evaluated: c <= '9'
TRUEFALSE
yes
Evaluation Count:26092
yes
Evaluation Count:337
337-26429
1577 if (nd < 9)
evaluated: nd < 9
TRUEFALSE
yes
Evaluation Count:7607
yes
Evaluation Count:18485
7607-18485
1578 y = 10*y + c - '0';
executed: y = 10*y + c - '0';
Execution Count:7607
7607
1579 else if (nd < 16)
evaluated: nd < 16
TRUEFALSE
yes
Evaluation Count:1464
yes
Evaluation Count:17021
1464-17021
1580 z = 10*z + c - '0';
executed: z = 10*z + c - '0';
Execution Count:1464
1464
1581 nd0 = nd;
executed (the execution status of this line is deduced): nd0 = nd;
-
1582 if (c == decimal_point) {
evaluated: c == decimal_point
TRUEFALSE
yes
Evaluation Count:1804
yes
Evaluation Count:1598
1598-1804
1583 c = *++s;
executed (the execution status of this line is deduced): c = *++s;
-
1584 if (!nd) {
evaluated: !nd
TRUEFALSE
yes
Evaluation Count:809
yes
Evaluation Count:995
809-995
1585 for(; c == '0'; c = *++s)
evaluated: c == '0'
TRUEFALSE
yes
Evaluation Count:3382
yes
Evaluation Count:809
809-3382
1586 nz++;
executed: nz++;
Execution Count:3382
3382
1587 if (c > '0' && c <= '9') {
evaluated: c > '0'
TRUEFALSE
yes
Evaluation Count:263
yes
Evaluation Count:546
evaluated: c <= '9'
TRUEFALSE
yes
Evaluation Count:260
yes
Evaluation Count:3
3-546
1588 s0 = s;
executed (the execution status of this line is deduced): s0 = s;
-
1589 nf += nz;
executed (the execution status of this line is deduced): nf += nz;
-
1590 nz = 0;
executed (the execution status of this line is deduced): nz = 0;
-
1591 goto have_dig;
executed: goto have_dig;
Execution Count:260
260
1592 } -
1593 goto dig_done;
executed: goto dig_done;
Execution Count:549
549
1594 } -
1595 for(; c >= '0' && c <= '9'; c = *++s) {
evaluated: c >= '0'
TRUEFALSE
yes
Evaluation Count:7102
yes
Evaluation Count:1213
evaluated: c <= '9'
TRUEFALSE
yes
Evaluation Count:7060
yes
Evaluation Count:42
42-7102
1596 have_dig: -
1597 nz++;
executed (the execution status of this line is deduced): nz++;
-
1598 if (c -= '0') {
evaluated: c -= '0'
TRUEFALSE
yes
Evaluation Count:3043
yes
Evaluation Count:4277
3043-4277
1599 nf += nz;
executed (the execution status of this line is deduced): nf += nz;
-
1600 for(i = 1; i < nz; i++)
evaluated: i < nz
TRUEFALSE
yes
Evaluation Count:101
yes
Evaluation Count:3043
101-3043
1601 if (nd++ < 9)
evaluated: nd++ < 9
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:45
45-56
1602 y *= 10;
executed: y *= 10;
Execution Count:56
56
1603 else if (nd <= DBL_DIG + 1)
evaluated: nd <= 15 + 1
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:30
15-30
1604 z *= 10;
executed: z *= 10;
Execution Count:15
15
1605 if (nd++ < 9)
evaluated: nd++ < 9
TRUEFALSE
yes
Evaluation Count:1729
yes
Evaluation Count:1314
1314-1729
1606 y = 10*y + c;
executed: y = 10*y + c;
Execution Count:1729
1729
1607 else if (nd <= DBL_DIG + 1)
evaluated: nd <= 15 + 1
TRUEFALSE
yes
Evaluation Count:640
yes
Evaluation Count:674
640-674
1608 z = 10*z + c;
executed: z = 10*z + c;
Execution Count:640
640
1609 nz = 0;
executed (the execution status of this line is deduced): nz = 0;
-
1610 }
executed: }
Execution Count:3043
3043
1611 }
executed: }
Execution Count:7320
7320
1612 }
executed: }
Execution Count:1255
1255
1613 dig_done:
code before this statement executed: dig_done:
Execution Count:2853
2853
1614 e = 0;
executed (the execution status of this line is deduced): e = 0;
-
1615 if (c == 'e' || c == 'E') {
evaluated: c == 'e'
TRUEFALSE
yes
Evaluation Count:147
yes
Evaluation Count:3255
evaluated: c == 'E'
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3245
10-3255
1616 if (!nd && !nz && !nz0) {
evaluated: !nd
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:137
partially evaluated: !nz
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
partially evaluated: !nz0
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-137
1617 s = s00;
executed (the execution status of this line is deduced): s = s00;
-
1618 goto ret;
executed: goto ret;
Execution Count:20
20
1619 } -
1620 s00 = s;
executed (the execution status of this line is deduced): s00 = s;
-
1621 esign = 0;
executed (the execution status of this line is deduced): esign = 0;
-
1622 switch(c = *++s) { -
1623 case '-': -
1624 esign = 1;
executed (the execution status of this line is deduced): esign = 1;
-
1625 case '+':
code before this statement executed: case '+':
Execution Count:42
42
1626 c = *++s;
executed (the execution status of this line is deduced): c = *++s;
-
1627 }
executed: }
Execution Count:88
88
1628 if (c >= '0' && c <= '9') {
evaluated: c >= '0'
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:25
evaluated: c <= '9'
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:1
1-112
1629 while(c == '0')
evaluated: c == '0'
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:111
34-111
1630 c = *++s;
executed: c = *++s;
Execution Count:34
34
1631 if (c > '0' && c <= '9') {
evaluated: c > '0'
TRUEFALSE
yes
Evaluation Count:99
yes
Evaluation Count:12
partially evaluated: c <= '9'
TRUEFALSE
yes
Evaluation Count:99
no
Evaluation Count:0
0-99
1632 L = c - '0';
executed (the execution status of this line is deduced): L = c - '0';
-
1633 s1 = s;
executed (the execution status of this line is deduced): s1 = s;
-
1634 while((c = *++s) >= '0' && c <= '9')
evaluated: (c = *++s) >= '0'
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:99
partially evaluated: c <= '9'
TRUEFALSE
yes
Evaluation Count:74
no
Evaluation Count:0
0-99
1635 L = 10*L + c - '0';
executed: L = 10*L + c - '0';
Execution Count:74
74
1636 if (s - s1 > 8 || L > 19999)
partially evaluated: s - s1 > 8
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:99
partially evaluated: L > 19999
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:99
0-99
1637 /* Avoid confusion from exponents -
1638 * so large that e might overflow. -
1639 */ -
1640 e = 19999; /* safe for 16 bit ints */
never executed: e = 19999;
0
1641 else -
1642 e = int(L);
executed: e = int(L);
Execution Count:99
99
1643 if (esign)
evaluated: esign
TRUEFALSE
yes
Evaluation Count:31
yes
Evaluation Count:68
31-68
1644 e = -e;
executed: e = -e;
Execution Count:31
31
1645 }
executed: }
Execution Count:99
99
1646 else -
1647 e = 0;
executed: e = 0;
Execution Count:12
12
1648 } -
1649 else -
1650 s = s00;
executed: s = s00;
Execution Count:26
26
1651 } -
1652 if (!nd) {
evaluated: !nd
TRUEFALSE
yes
Evaluation Count:770
yes
Evaluation Count:2612
770-2612
1653 if (!nz && !nz0)
evaluated: !nz
TRUEFALSE
yes
Evaluation Count:307
yes
Evaluation Count:463
evaluated: !nz0
TRUEFALSE
yes
Evaluation Count:225
yes
Evaluation Count:82
82-463
1654 s = s00;
executed: s = s00;
Execution Count:225
225
1655 goto ret;
executed: goto ret;
Execution Count:770
770
1656 } -
1657 e1 = e -= nf;
executed (the execution status of this line is deduced): e1 = e -= nf;
-
1658 -
1659 /* Now we have nd0 digits, starting at s0, followed by a -
1660 * decimal point, followed by nd-nd0 digits. The number we're -
1661 * after is the integer represented by those digits times -
1662 * 10**e */ -
1663 -
1664 if (!nd0)
evaluated: !nd0
TRUEFALSE
yes
Evaluation Count:260
yes
Evaluation Count:2352
260-2352
1665 nd0 = nd;
executed: nd0 = nd;
Execution Count:260
260
1666 k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1;
evaluated: nd < 15 + 1
TRUEFALSE
yes
Evaluation Count:2463
yes
Evaluation Count:149
149-2463
1667 rv = y;
executed (the execution status of this line is deduced): rv = y;
-
1668 if (k > 9)
evaluated: k > 9
TRUEFALSE
yes
Evaluation Count:488
yes
Evaluation Count:2124
488-2124
1669#if defined(Q_OS_IRIX) && defined(Q_CC_GNU) -
1670 { -
1671 // work around a bug on 64 bit IRIX gcc -
1672 double *t = (double *) tens; -
1673 rv = t[k - 9] * rv + z; -
1674 } -
1675#else -
1676 rv = tens[k - 9] * rv + z;
executed: rv = tens[k - 9] * rv + z;
Execution Count:488
488
1677#endif -
1678 -
1679 bd0 = 0;
executed (the execution status of this line is deduced): bd0 = 0;
-
1680 if (nd <= DBL_DIG
evaluated: nd <= 15
TRUEFALSE
yes
Evaluation Count:2463
yes
Evaluation Count:149
149-2463
1681#ifndef RND_PRODQUOT
executed (the execution status of this line is deduced):
-
1682 && FLT_ROUNDS == 1
partially evaluated: 1 == 1
TRUEFALSE
yes
Evaluation Count:2463
no
Evaluation Count:0
0-2463
1683#endif -
1684 ) { -
1685 if (!e)
evaluated: !e
TRUEFALSE
yes
Evaluation Count:1945
yes
Evaluation Count:518
518-1945
1686 goto ret;
executed: goto ret;
Execution Count:1945
1945
1687 if (e > 0) {
evaluated: e > 0
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:463
55-463
1688 if (e <= Ten_pmax) {
evaluated: e <= 22
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:16
16-39
1689#ifdef VAX -
1690 goto vax_ovfl_check; -
1691#else -
1692 /* rv = */ rounded_product(rv, tens[e]);
executed (the execution status of this line is deduced): rv *= tens[e];
-
1693 goto ret;
executed: goto ret;
Execution Count:39
39
1694#endif -
1695 } -
1696 i = DBL_DIG - nd;
executed (the execution status of this line is deduced): i = 15 - nd;
-
1697 if (e <= Ten_pmax + i) {
evaluated: e <= 22 + i
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:12
4-12
1698 /* A fancier test would sometimes let us do -
1699 * this for larger i values. -
1700 */ -
1701 e -= i;
executed (the execution status of this line is deduced): e -= i;
-
1702 rv *= tens[i];
executed (the execution status of this line is deduced): rv *= tens[i];
-
1703#ifdef VAX -
1704 /* VAX exponent range is so narrow we must -
1705 * worry about overflow here... -
1706 */ -
1707 vax_ovfl_check: -
1708 setWord0(&rv, getWord0(rv) - P*Exp_msk1); -
1709 /* rv = */ rounded_product(rv, tens[e]); -
1710 if ((getWord0(rv) & Exp_mask) -
1711 > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) -
1712 goto ovfl; -
1713 setWord0(&rv, getWord0(rv) + P*Exp_msk1); -
1714#else -
1715 /* rv = */ rounded_product(rv, tens[e]);
executed (the execution status of this line is deduced): rv *= tens[e];
-
1716#endif -
1717 goto ret;
executed: goto ret;
Execution Count:4
4
1718 } -
1719 }
executed: }
Execution Count:12
12
1720#ifndef Inaccurate_Divide -
1721 else if (e >= -Ten_pmax) {
evaluated: e >= -22
TRUEFALSE
yes
Evaluation Count:459
yes
Evaluation Count:4
4-459
1722 /* rv = */ rounded_quotient(rv, tens[-e]);
executed (the execution status of this line is deduced): rv /= tens[-e];
-
1723 goto ret;
executed: goto ret;
Execution Count:459
459
1724 } -
1725#endif -
1726 } -
1727 e1 += nd - k;
executed (the execution status of this line is deduced): e1 += nd - k;
-
1728 -
1729 /* Get starting approximation = rv * 10**e1 */ -
1730 -
1731 if (e1 > 0) {
evaluated: e1 > 0
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:87
78-87
1732 if ((i = e1 & 15) != 0)
evaluated: (i = e1 & 15) != 0
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:1
1-77
1733 rv *= tens[i];
executed: rv *= tens[i];
Execution Count:77
77
1734 if (e1 &= ~15) {
evaluated: e1 &= ~15
TRUEFALSE
yes
Evaluation Count:77
yes
Evaluation Count:1
1-77
1735 if (e1 > DBL_MAX_10_EXP) {
evaluated: e1 > 308
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:75
2-75
1736 ovfl: -
1737 // errno = ERANGE; -
1738 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1739 *ok = false;
executed: *ok = false;
Execution Count:2
2
1740#ifdef __STDC__ -
1741 rv = HUGE_VAL;
executed (the execution status of this line is deduced): rv = (__builtin_huge_val());
-
1742#else -
1743 /* Can't trust HUGE_VAL */ -
1744#ifdef IEEE_Arith -
1745 setWord0(&rv, Exp_mask); -
1746 setWord1(&rv, 0); -
1747#else -
1748 setWord0(&rv, Big0); -
1749 setWord1(&rv, Big1); -
1750#endif -
1751#endif -
1752 if (bd0)
partially evaluated: bd0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1753 goto retfree;
never executed: goto retfree;
0
1754 goto ret;
executed: goto ret;
Execution Count:2
2
1755 } -
1756 if (e1 >>= 4) {
partially evaluated: e1 >>= 4
TRUEFALSE
yes
Evaluation Count:75
no
Evaluation Count:0
0-75
1757 for(j = 0; e1 > 1; j++, e1 >>= 1)
evaluated: e1 > 1
TRUEFALSE
yes
Evaluation Count:264
yes
Evaluation Count:75
75-264
1758 if (e1 & 1)
evaluated: e1 & 1
TRUEFALSE
yes
Evaluation Count:70
yes
Evaluation Count:194
70-194
1759 rv *= bigtens[j];
executed: rv *= bigtens[j];
Execution Count:70
70
1760 /* The last multiplication could overflow. */ -
1761 setWord0(&rv, getWord0(rv) - P*Exp_msk1);
executed (the execution status of this line is deduced): setWord0(&rv, getWord0(rv) - 53*0x100000);
-
1762 rv *= bigtens[j];
executed (the execution status of this line is deduced): rv *= bigtens[j];
-
1763 if ((z = getWord0(rv) & Exp_mask)
partially evaluated: (z = getWord0(rv) & 0x7ff00000) > 0x100000*(1024 +1023 -53)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75
0-75
1764 > Exp_msk1*(DBL_MAX_EXP+Bias-P))
partially evaluated: (z = getWord0(rv) & 0x7ff00000) > 0x100000*(1024 +1023 -53)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75
0-75
1765 goto ovfl;
never executed: goto ovfl;
0
1766 if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) {
partially evaluated: z > 0x100000*(1024 +1023 -1-53)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:75
0-75
1767 /* set to largest number */ -
1768 /* (Can't trust DBL_MAX) */ -
1769 setWord0(&rv, Big0);
never executed (the execution status of this line is deduced): setWord0(&rv, (0xfffff | 0x100000*(1024 +1023 -1)));
-
1770 setWord1(&rv, Big1);
never executed (the execution status of this line is deduced): setWord1(&rv, 0xffffffff);
-
1771 }
never executed: }
0
1772 else -
1773 setWord0(&rv, getWord0(rv) + P*Exp_msk1);
executed: setWord0(&rv, getWord0(rv) + 53*0x100000);
Execution Count:75
75
1774 } -
1775 -
1776 }
executed: }
Execution Count:75
75
1777 }
executed: }
Execution Count:76
76
1778 else if (e1 < 0) {
partially evaluated: e1 < 0
TRUEFALSE
yes
Evaluation Count:87
no
Evaluation Count:0
0-87
1779 e1 = -e1;
executed (the execution status of this line is deduced): e1 = -e1;
-
1780 if ((i = e1 & 15) != 0)
evaluated: (i = e1 & 15) != 0
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:63
24-63
1781 rv /= tens[i];
executed: rv /= tens[i];
Execution Count:24
24
1782 if (e1 &= ~15) {
evaluated: e1 &= ~15
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:19
19-68
1783 e1 >>= 4;
executed (the execution status of this line is deduced): e1 >>= 4;
-
1784 if (e1 >= 1 << n_bigtens)
evaluated: e1 >= 1 << 5
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:66
2-66
1785 goto undfl;
executed: goto undfl;
Execution Count:2
2
1786 for(j = 0; e1 > 1; j++, e1 >>= 1)
evaluated: e1 > 1
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:66
8-66
1787 if (e1 & 1)
evaluated: e1 & 1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
1788 rv *= tinytens[j];
executed: rv *= tinytens[j];
Execution Count:4
4
1789 /* The last multiplication could underflow. */ -
1790 rv0 = rv;
executed (the execution status of this line is deduced): rv0 = rv;
-
1791 rv *= tinytens[j];
executed (the execution status of this line is deduced): rv *= tinytens[j];
-
1792 if (rv == g_double_zero)
partially evaluated: rv == g_double_zero
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:66
0-66
1793 { -
1794 rv = 2.*rv0;
never executed (the execution status of this line is deduced): rv = 2.*rv0;
-
1795 rv *= tinytens[j];
never executed (the execution status of this line is deduced): rv *= tinytens[j];
-
1796 if (rv == g_double_zero)
never evaluated: rv == g_double_zero
0
1797 { -
1798 undfl: -
1799 rv = 0.;
executed (the execution status of this line is deduced): rv = 0.;
-
1800 // errno = ERANGE; -
1801 if (ok != 0)
partially evaluated: ok != 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1802 *ok = false;
executed: *ok = false;
Execution Count:2
2
1803 if (bd0)
partially evaluated: bd0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1804 goto retfree;
never executed: goto retfree;
0
1805 goto ret;
executed: goto ret;
Execution Count:2
2
1806 } -
1807 setWord0(&rv, Tiny0);
never executed (the execution status of this line is deduced): setWord0(&rv, 0);
-
1808 setWord1(&rv, Tiny1);
never executed (the execution status of this line is deduced): setWord1(&rv, 1);
-
1809 /* The refinement below will clean -
1810 * this approximation up. -
1811 */ -
1812 }
never executed: }
0
1813 }
executed: }
Execution Count:66
66
1814 }
executed: }
Execution Count:85
85
1815 -
1816 /* Now the hard part -- adjusting rv to the correct value.*/ -
1817 -
1818 /* Put digits into bd: true value = bd * 10^e */ -
1819 -
1820 bd0 = s2b(s0, nd0, nd, y);
executed (the execution status of this line is deduced): bd0 = s2b(s0, nd0, nd, y);
-
1821 -
1822 for(;;) {
executed (the execution status of this line is deduced): for(;;) {
-
1823 bd = Balloc(bd0->k);
executed (the execution status of this line is deduced): bd = Balloc(bd0->k);
-
1824 Bcopy(bd, bd0);
executed (the execution status of this line is deduced): memcpy(reinterpret_cast<char *>(&bd->sign), reinterpret_cast<char *>(&bd0->sign), bd0->wds*sizeof(qint32) + 2*sizeof(int));
-
1825 bb = d2b(rv, &bbe, &bbbits); /* rv = bb * 2^bbe */
executed (the execution status of this line is deduced): bb = d2b(rv, &bbe, &bbbits);
-
1826 bs = i2b(1);
executed (the execution status of this line is deduced): bs = i2b(1);
-
1827 -
1828 if (e >= 0) {
evaluated: e >= 0
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:87
76-87
1829 bb2 = bb5 = 0;
executed (the execution status of this line is deduced): bb2 = bb5 = 0;
-
1830 bd2 = bd5 = e;
executed (the execution status of this line is deduced): bd2 = bd5 = e;
-
1831 }
executed: }
Execution Count:76
76
1832 else { -
1833 bb2 = bb5 = -e;
executed (the execution status of this line is deduced): bb2 = bb5 = -e;
-
1834 bd2 = bd5 = 0;
executed (the execution status of this line is deduced): bd2 = bd5 = 0;
-
1835 }
executed: }
Execution Count:87
87
1836 if (bbe >= 0)
evaluated: bbe >= 0
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:85
78-85
1837 bb2 += bbe;
executed: bb2 += bbe;
Execution Count:78
78
1838 else -
1839 bd2 -= bbe;
executed: bd2 -= bbe;
Execution Count:85
85
1840 bs2 = bb2;
executed (the execution status of this line is deduced): bs2 = bb2;
-
1841#ifdef Sudden_Underflow -
1842#ifdef IBM -
1843 j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); -
1844#else -
1845 j = P + 1 - bbbits; -
1846#endif -
1847#else -
1848 i = bbe + bbbits - 1; /* logb(rv) */
executed (the execution status of this line is deduced): i = bbe + bbbits - 1;
-
1849 if (i < Emin) /* denormal */
evaluated: i < (-1022)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:161
2-161
1850 j = bbe + (P-Emin);
executed: j = bbe + (53 -(-1022));
Execution Count:2
2
1851 else -
1852 j = P + 1 - bbbits;
executed: j = 53 + 1 - bbbits;
Execution Count:161
161
1853#endif -
1854 bb2 += j;
executed (the execution status of this line is deduced): bb2 += j;
-
1855 bd2 += j;
executed (the execution status of this line is deduced): bd2 += j;
-
1856 i = bb2 < bd2 ? bb2 : bd2;
evaluated: bb2 < bd2
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:80
80-83
1857 if (i > bs2)
evaluated: i > bs2
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:76
76-87
1858 i = bs2;
executed: i = bs2;
Execution Count:87
87
1859 if (i > 0) {
partially evaluated: i > 0
TRUEFALSE
yes
Evaluation Count:163
no
Evaluation Count:0
0-163
1860 bb2 -= i;
executed (the execution status of this line is deduced): bb2 -= i;
-
1861 bd2 -= i;
executed (the execution status of this line is deduced): bd2 -= i;
-
1862 bs2 -= i;
executed (the execution status of this line is deduced): bs2 -= i;
-
1863 }
executed: }
Execution Count:163
163
1864 if (bb5 > 0) {
evaluated: bb5 > 0
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:76
76-87
1865 bs = pow5mult(bs, bb5);
executed (the execution status of this line is deduced): bs = pow5mult(bs, bb5);
-
1866 bb1 = mult(bs, bb);
executed (the execution status of this line is deduced): bb1 = mult(bs, bb);
-
1867 Bfree(bb);
executed (the execution status of this line is deduced): Bfree(bb);
-
1868 bb = bb1;
executed (the execution status of this line is deduced): bb = bb1;
-
1869 }
executed: }
Execution Count:87
87
1870 if (bb2 > 0)
partially evaluated: bb2 > 0
TRUEFALSE
yes
Evaluation Count:163
no
Evaluation Count:0
0-163
1871 bb = lshift(bb, bb2);
executed: bb = lshift(bb, bb2);
Execution Count:163
163
1872 if (bd5 > 0)
evaluated: bd5 > 0
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:147
16-147
1873 bd = pow5mult(bd, bd5);
executed: bd = pow5mult(bd, bd5);
Execution Count:16
16
1874 if (bd2 > 0)
evaluated: bd2 > 0
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:76
76-87
1875 bd = lshift(bd, bd2);
executed: bd = lshift(bd, bd2);
Execution Count:87
87
1876 if (bs2 > 0)
evaluated: bs2 > 0
TRUEFALSE
yes
Evaluation Count:76
yes
Evaluation Count:87
76-87
1877 bs = lshift(bs, bs2);
executed: bs = lshift(bs, bs2);
Execution Count:76
76
1878 delta = diff(bb, bd);
executed (the execution status of this line is deduced): delta = diff(bb, bd);
-
1879 dsign = delta->sign;
executed (the execution status of this line is deduced): dsign = delta->sign;
-
1880 delta->sign = 0;
executed (the execution status of this line is deduced): delta->sign = 0;
-
1881 i = cmp(delta, bs);
executed (the execution status of this line is deduced): i = cmp(delta, bs);
-
1882 if (i < 0) {
evaluated: i < 0
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:133
30-133
1883 /* Error is less than half an ulp -- check for -
1884 * special case of mantissa a power of two. -
1885 */ -
1886 if (dsign || getWord1(rv) || getWord0(rv) & Bndry_mask)
evaluated: dsign
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:20
evaluated: getWord1(rv)
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:3
partially evaluated: getWord0(rv) & 0xfffff
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-20
1887 break;
executed: break;
Execution Count:27
27
1888 delta = lshift(delta,Log2P);
executed (the execution status of this line is deduced): delta = lshift(delta,1);
-
1889 if (cmp(delta, bs) > 0)
evaluated: cmp(delta, bs) > 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1890 goto drop_down;
executed: goto drop_down;
Execution Count:1
1
1891 break;
executed: break;
Execution Count:2
2
1892 } -
1893 if (i == 0) {
partially evaluated: i == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:133
0-133
1894 /* exactly half-way between */ -
1895 if (dsign) {
never evaluated: dsign
0
1896 if ((getWord0(rv) & Bndry_mask1) == Bndry_mask1
never evaluated: (getWord0(rv) & 0xfffff) == 0xfffff
0
1897 && getWord1(rv) == 0xffffffff) {
never evaluated: getWord1(rv) == 0xffffffff
0
1898 /*boundary case -- increment exponent*/ -
1899 setWord0(&rv, (getWord0(rv) & Exp_mask)
never executed (the execution status of this line is deduced): setWord0(&rv, (getWord0(rv) & 0x7ff00000)
-
1900 + Exp_msk1
never executed (the execution status of this line is deduced): + 0x100000
-
1901#ifdef IBM
never executed (the execution status of this line is deduced):
-
1902 | Exp_msk1 >> 4
never executed (the execution status of this line is deduced):
-
1903#endif
never executed (the execution status of this line is deduced):
-
1904 );
never executed (the execution status of this line is deduced): );
-
1905 setWord1(&rv, 0);
never executed (the execution status of this line is deduced): setWord1(&rv, 0);
-
1906 break;
never executed: break;
0
1907 } -
1908 }
never executed: }
0
1909 else if (!(getWord0(rv) & Bndry_mask) && !getWord1(rv)) {
never evaluated: !(getWord0(rv) & 0xfffff)
never evaluated: !getWord1(rv)
0
1910 drop_down: -
1911 /* boundary case -- decrement exponent */ -
1912#ifdef Sudden_Underflow -
1913 L = getWord0(rv) & Exp_mask; -
1914#ifdef IBM -
1915 if (L < Exp_msk1) -
1916#else -
1917 if (L <= Exp_msk1) -
1918#endif -
1919 goto undfl; -
1920 L -= Exp_msk1; -
1921#else -
1922 L = (getWord0(rv) & Exp_mask) - Exp_msk1;
executed (the execution status of this line is deduced): L = (getWord0(rv) & 0x7ff00000) - 0x100000;
-
1923#endif -
1924 setWord0(&rv, L | Bndry_mask1);
executed (the execution status of this line is deduced): setWord0(&rv, L | 0xfffff);
-
1925 setWord1(&rv, 0xffffffff);
executed (the execution status of this line is deduced): setWord1(&rv, 0xffffffff);
-
1926#ifdef IBM -
1927 goto cont; -
1928#else -
1929 break;
executed: break;
Execution Count:1
1
1930#endif -
1931 } -
1932#ifndef ROUND_BIASED -
1933 if (!(getWord1(rv) & LSB))
never evaluated: !(getWord1(rv) & 1)
0
1934 break;
never executed: break;
0
1935#endif -
1936 if (dsign)
never evaluated: dsign
0
1937 rv += ulp(rv);
never executed: rv += ulp(rv);
0
1938#ifndef ROUND_BIASED -
1939 else { -
1940 rv -= ulp(rv);
never executed (the execution status of this line is deduced): rv -= ulp(rv);
-
1941#ifndef Sudden_Underflow -
1942 if (rv == g_double_zero)
never evaluated: rv == g_double_zero
0
1943 goto undfl;
never executed: goto undfl;
0
1944#endif -
1945 }
never executed: }
0
1946#endif -
1947 break;
never executed: break;
0
1948 } -
1949 if ((aadj = ratio(delta, bs)) <= 2.) {
evaluated: (aadj = ratio(delta, bs)) <= 2.
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:118
15-118
1950 if (dsign)
evaluated: dsign
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:4
4-11
1951 aadj = aadj1 = 1.;
executed: aadj = aadj1 = 1.;
Execution Count:11
11
1952 else if (getWord1(rv) || getWord0(rv) & Bndry_mask) {
partially evaluated: getWord1(rv)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
never evaluated: getWord0(rv) & 0xfffff
0-4
1953#ifndef Sudden_Underflow -
1954 if (getWord1(rv) == Tiny1 && !getWord0(rv))
partially evaluated: getWord1(rv) == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
never evaluated: !getWord0(rv)
0-4
1955 goto undfl;
never executed: goto undfl;
0
1956#endif -
1957 aadj = 1.;
executed (the execution status of this line is deduced): aadj = 1.;
-
1958 aadj1 = -1.;
executed (the execution status of this line is deduced): aadj1 = -1.;
-
1959 }
executed: }
Execution Count:4
4
1960 else { -
1961 /* special case -- power of FLT_RADIX to be */ -
1962 /* rounded down... */ -
1963 -
1964 if (aadj < 2./FLT_RADIX)
never evaluated: aadj < 2./2
0
1965 aadj = 1./FLT_RADIX;
never executed: aadj = 1./2;
0
1966 else -
1967 aadj *= 0.5;
never executed: aadj *= 0.5;
0
1968 aadj1 = -aadj;
never executed (the execution status of this line is deduced): aadj1 = -aadj;
-
1969 }
never executed: }
0
1970 } -
1971 else { -
1972 aadj *= 0.5;
executed (the execution status of this line is deduced): aadj *= 0.5;
-
1973 aadj1 = dsign ? aadj : -aadj;
partially evaluated: dsign
TRUEFALSE
yes
Evaluation Count:118
no
Evaluation Count:0
0-118
1974#ifdef Check_FLT_ROUNDS -
1975 switch(FLT_ROUNDS) { -
1976 case 2: /* towards +infinity */ -
1977 aadj1 -= 0.5; -
1978 break; -
1979 case 0: /* towards 0 */ -
1980 case 3: /* towards -infinity */ -
1981 aadj1 += 0.5; -
1982 } -
1983#else -
1984 if (FLT_ROUNDS == 0)
partially evaluated: 1 == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:118
0-118
1985 aadj1 += 0.5;
never executed: aadj1 += 0.5;
0
1986#endif -
1987 }
executed: }
Execution Count:118
118
1988 y = getWord0(rv) & Exp_mask;
executed (the execution status of this line is deduced): y = getWord0(rv) & 0x7ff00000;
-
1989 -
1990 /* Check for overflow */ -
1991 -
1992 if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) {
evaluated: y == 0x100000*(1024 +1023 -1)
TRUEFALSE
yes
Evaluation Count:62
yes
Evaluation Count:71
62-71
1993 rv0 = rv;
executed (the execution status of this line is deduced): rv0 = rv;
-
1994 setWord0(&rv, getWord0(rv) - P*Exp_msk1);
executed (the execution status of this line is deduced): setWord0(&rv, getWord0(rv) - 53*0x100000);
-
1995 adj = aadj1 * ulp(rv);
executed (the execution status of this line is deduced): adj = aadj1 * ulp(rv);
-
1996 rv += adj;
executed (the execution status of this line is deduced): rv += adj;
-
1997 if ((getWord0(rv) & Exp_mask) >=
partially evaluated: (getWord0(rv) & 0x7ff00000) >= 0x100000*(1024 +1023 -53)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:62
0-62
1998 Exp_msk1*(DBL_MAX_EXP+Bias-P)) {
partially evaluated: (getWord0(rv) & 0x7ff00000) >= 0x100000*(1024 +1023 -53)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:62
0-62
1999 if (getWord0(rv0) == Big0 && getWord1(rv0) == Big1)
never evaluated: getWord0(rv0) == (0xfffff | 0x100000*(1024 +1023 -1))
never evaluated: getWord1(rv0) == 0xffffffff
0
2000 goto ovfl;
never executed: goto ovfl;
0
2001 setWord0(&rv, Big0);
never executed (the execution status of this line is deduced): setWord0(&rv, (0xfffff | 0x100000*(1024 +1023 -1)));
-
2002 setWord1(&rv, Big1);
never executed (the execution status of this line is deduced): setWord1(&rv, 0xffffffff);
-
2003 goto cont;
never executed: goto cont;
0
2004 } -
2005 else -
2006 setWord0(&rv, getWord0(rv) + P*Exp_msk1);
executed: setWord0(&rv, getWord0(rv) + 53*0x100000);
Execution Count:62
62
2007 } -
2008 else { -
2009#ifdef Sudden_Underflow -
2010 if ((getWord0(rv) & Exp_mask) <= P*Exp_msk1) { -
2011 rv0 = rv; -
2012 setWord0(&rv, getWord0(rv) + P*Exp_msk1); -
2013 adj = aadj1 * ulp(rv); -
2014 rv += adj; -
2015#ifdef IBM -
2016 if ((getWord0(rv) & Exp_mask) < P*Exp_msk1) -
2017#else -
2018 if ((getWord0(rv) & Exp_mask) <= P*Exp_msk1) -
2019#endif -
2020 { -
2021 if (getWord0(rv0) == Tiny0 -
2022 && getWord1(rv0) == Tiny1) -
2023 goto undfl; -
2024 setWord0(&rv, Tiny0); -
2025 setWord1(&rv, Tiny1); -
2026 goto cont; -
2027 } -
2028 else -
2029 setWord0(&rv, getWord0(rv) - P*Exp_msk1); -
2030 } -
2031 else { -
2032 adj = aadj1 * ulp(rv); -
2033 rv += adj; -
2034 } -
2035#else -
2036 /* Compute adj so that the IEEE rounding rules will -
2037 * correctly round rv + adj in some half-way cases. -
2038 * If rv * ulp(rv) is denormalized (i.e., -
2039 * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid -
2040 * trouble from bits lost to denormalization; -
2041 * example: 1.2e-307 . -
2042 */ -
2043 if (y <= (P-1)*Exp_msk1 && aadj >= 1.) {
partially evaluated: y <= (53 -1)*0x100000
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:71
never evaluated: aadj >= 1.
0-71
2044 aadj1 = int(aadj + 0.5);
never executed (the execution status of this line is deduced): aadj1 = int(aadj + 0.5);
-
2045 if (!dsign)
never evaluated: !dsign
0
2046 aadj1 = -aadj1;
never executed: aadj1 = -aadj1;
0
2047 }
never executed: }
0
2048 adj = aadj1 * ulp(rv);
executed (the execution status of this line is deduced): adj = aadj1 * ulp(rv);
-
2049 rv += adj;
executed (the execution status of this line is deduced): rv += adj;
-
2050#endif -
2051 }
executed: }
Execution Count:71
71
2052 z = getWord0(rv) & Exp_mask;
executed (the execution status of this line is deduced): z = getWord0(rv) & 0x7ff00000;
-
2053 if (y == z) {
evaluated: y == z
TRUEFALSE
yes
Evaluation Count:131
yes
Evaluation Count:2
2-131
2054 /* Can we stop now? */ -
2055 L = Long(aadj);
never executed (the execution status of this line is deduced): L = qint32(aadj);
-
2056 aadj -= L;
never executed (the execution status of this line is deduced): aadj -= L;
-
2057 /* The tolerances below are conservative. */ -
2058 if (dsign || getWord1(rv) || getWord0(rv) & Bndry_mask) {
evaluated: dsign
TRUEFALSE
yes
Evaluation Count:127
yes
Evaluation Count:4
partially evaluated: getWord1(rv)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
never evaluated: getWord0(rv) & 0xfffff
0-127
2059 if (aadj < .4999999 || aadj > .5000001)
evaluated: aadj < .4999999
TRUEFALSE
yes
Evaluation Count:119
yes
Evaluation Count:12
partially evaluated: aadj > .5000001
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-119
2060 break;
executed: break;
Execution Count:131
131
2061 }
never executed: }
0
2062 else if (aadj < .4999999/FLT_RADIX)
never evaluated: aadj < .4999999/2
0
2063 break;
never executed: break;
0
2064 } -
2065 cont:
code before this statement executed: cont:
Execution Count:2
2
2066 Bfree(bb);
executed (the execution status of this line is deduced): Bfree(bb);
-
2067 Bfree(bd);
executed (the execution status of this line is deduced): Bfree(bd);
-
2068 Bfree(bs);
executed (the execution status of this line is deduced): Bfree(bs);
-
2069 Bfree(delta);
executed (the execution status of this line is deduced): Bfree(delta);
-
2070 }
executed: }
Execution Count:2
2
2071 retfree:
code before this statement executed: retfree:
Execution Count:161
161
2072 Bfree(bb);
executed (the execution status of this line is deduced): Bfree(bb);
-
2073 Bfree(bd);
executed (the execution status of this line is deduced): Bfree(bd);
-
2074 Bfree(bs);
executed (the execution status of this line is deduced): Bfree(bs);
-
2075 Bfree(bd0);
executed (the execution status of this line is deduced): Bfree(bd0);
-
2076 Bfree(delta);
executed (the execution status of this line is deduced): Bfree(delta);
-
2077 ret:
code before this statement executed: ret:
Execution Count:161
161
2078 if (se)
partially evaluated: se
TRUEFALSE
yes
Evaluation Count:4149
no
Evaluation Count:0
0-4149
2079 *se = s;
executed: *se = s;
Execution Count:4149
4149
2080 return sign ? -rv : rv;
executed: return sign ? -rv : rv;
Execution Count:4149
4149
2081} -
2082 -
2083static int quorem(Bigint *b, Bigint *S) -
2084{ -
2085 int n;
executed (the execution status of this line is deduced): int n;
-
2086 Long borrow, y;
executed (the execution status of this line is deduced): qint32 borrow, y;
-
2087 ULong carry, q, ys;
executed (the execution status of this line is deduced): quint32 carry, q, ys;
-
2088 ULong *bx, *bxe, *sx, *sxe;
executed (the execution status of this line is deduced): quint32 *bx, *bxe, *sx, *sxe;
-
2089#ifdef Pack_32 -
2090 Long z;
executed (the execution status of this line is deduced): qint32 z;
-
2091 ULong si, zs;
executed (the execution status of this line is deduced): quint32 si, zs;
-
2092#endif -
2093 -
2094 n = S->wds;
executed (the execution status of this line is deduced): n = S->wds;
-
2095#ifdef BSD_QDTOA_DEBUG -
2096 /*debug*/ if (b->wds > n) -
2097 /*debug*/ Bug("oversize b in quorem"); -
2098#endif -
2099 if (b->wds < n)
evaluated: b->wds < n
TRUEFALSE
yes
Evaluation Count:3865
yes
Evaluation Count:120577
3865-120577
2100 return 0;
executed: return 0;
Execution Count:3865
3865
2101 sx = S->x;
executed (the execution status of this line is deduced): sx = S->x;
-
2102 sxe = sx + --n;
executed (the execution status of this line is deduced): sxe = sx + --n;
-
2103 bx = b->x;
executed (the execution status of this line is deduced): bx = b->x;
-
2104 bxe = bx + n;
executed (the execution status of this line is deduced): bxe = bx + n;
-
2105 q = *bxe / (*sxe + 1); /* ensure q <= true quotient */
executed (the execution status of this line is deduced): q = *bxe / (*sxe + 1);
-
2106#ifdef BSD_QDTOA_DEBUG -
2107 /*debug*/ if (q > 9) -
2108 /*debug*/ Bug("oversized quotient in quorem"); -
2109#endif -
2110 if (q) {
evaluated: q
TRUEFALSE
yes
Evaluation Count:110845
yes
Evaluation Count:9732
9732-110845
2111 borrow = 0;
executed (the execution status of this line is deduced): borrow = 0;
-
2112 carry = 0;
executed (the execution status of this line is deduced): carry = 0;
-
2113 do { -
2114#ifdef Pack_32 -
2115 si = *sx++;
executed (the execution status of this line is deduced): si = *sx++;
-
2116 ys = (si & 0xffff) * q + carry;
executed (the execution status of this line is deduced): ys = (si & 0xffff) * q + carry;
-
2117 zs = (si >> 16) * q + (ys >> 16);
executed (the execution status of this line is deduced): zs = (si >> 16) * q + (ys >> 16);
-
2118 carry = zs >> 16;
executed (the execution status of this line is deduced): carry = zs >> 16;
-
2119 y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
executed (the execution status of this line is deduced): y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
-
2120 borrow = y >> 16;
executed (the execution status of this line is deduced): borrow = y >> 16;
-
2121 Sign_Extend(borrow, y); -
2122 z = (*bx >> 16) - (zs & 0xffff) + borrow;
executed (the execution status of this line is deduced): z = (*bx >> 16) - (zs & 0xffff) + borrow;
-
2123 borrow = z >> 16;
executed (the execution status of this line is deduced): borrow = z >> 16;
-
2124 Sign_Extend(borrow, z); -
2125 Storeinc(bx, z, y);
executed (the execution status of this line is deduced): Storeinc(bx, z, y);
-
2126#else -
2127 ys = *sx++ * q + carry; -
2128 carry = ys >> 16; -
2129 y = *bx - (ys & 0xffff) + borrow; -
2130 borrow = y >> 16; -
2131 Sign_Extend(borrow, y); -
2132 *bx++ = y & 0xffff; -
2133#endif -
2134 }
executed: }
Execution Count:899957
899957
2135 while(sx <= sxe);
evaluated: sx <= sxe
TRUEFALSE
yes
Evaluation Count:789112
yes
Evaluation Count:110845
110845-789112
2136 if (!*bxe) {
partially evaluated: !*bxe
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:110845
0-110845
2137 bx = b->x;
never executed (the execution status of this line is deduced): bx = b->x;
-
2138 while(--bxe > bx && !*bxe)
never evaluated: --bxe > bx
never evaluated: !*bxe
0
2139 --n;
never executed: --n;
0
2140 b->wds = n;
never executed (the execution status of this line is deduced): b->wds = n;
-
2141 }
never executed: }
0
2142 }
executed: }
Execution Count:110845
110845
2143 if (cmp(b, S) >= 0) {
evaluated: cmp(b, S) >= 0
TRUEFALSE
yes
Evaluation Count:582
yes
Evaluation Count:119995
582-119995
2144 q++;
executed (the execution status of this line is deduced): q++;
-
2145 borrow = 0;
executed (the execution status of this line is deduced): borrow = 0;
-
2146 carry = 0;
executed (the execution status of this line is deduced): carry = 0;
-
2147 bx = b->x;
executed (the execution status of this line is deduced): bx = b->x;
-
2148 sx = S->x;
executed (the execution status of this line is deduced): sx = S->x;
-
2149 do { -
2150#ifdef Pack_32 -
2151 si = *sx++;
executed (the execution status of this line is deduced): si = *sx++;
-
2152 ys = (si & 0xffff) + carry;
executed (the execution status of this line is deduced): ys = (si & 0xffff) + carry;
-
2153 zs = (si >> 16) + (ys >> 16);
executed (the execution status of this line is deduced): zs = (si >> 16) + (ys >> 16);
-
2154 carry = zs >> 16;
executed (the execution status of this line is deduced): carry = zs >> 16;
-
2155 y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
executed (the execution status of this line is deduced): y = (*bx & 0xffff) - (ys & 0xffff) + borrow;
-
2156 borrow = y >> 16;
executed (the execution status of this line is deduced): borrow = y >> 16;
-
2157 Sign_Extend(borrow, y); -
2158 z = (*bx >> 16) - (zs & 0xffff) + borrow;
executed (the execution status of this line is deduced): z = (*bx >> 16) - (zs & 0xffff) + borrow;
-
2159 borrow = z >> 16;
executed (the execution status of this line is deduced): borrow = z >> 16;
-
2160 Sign_Extend(borrow, z); -
2161 Storeinc(bx, z, y);
executed (the execution status of this line is deduced): Storeinc(bx, z, y);
-
2162#else -
2163 ys = *sx++ + carry; -
2164 carry = ys >> 16; -
2165 y = *bx - (ys & 0xffff) + borrow; -
2166 borrow = y >> 16; -
2167 Sign_Extend(borrow, y); -
2168 *bx++ = y & 0xffff; -
2169#endif -
2170 }
executed: }
Execution Count:2767
2767
2171 while(sx <= sxe);
evaluated: sx <= sxe
TRUEFALSE
yes
Evaluation Count:2185
yes
Evaluation Count:582
582-2185
2172 bx = b->x;
executed (the execution status of this line is deduced): bx = b->x;
-
2173 bxe = bx + n;
executed (the execution status of this line is deduced): bxe = bx + n;
-
2174 if (!*bxe) {
partially evaluated: !*bxe
TRUEFALSE
yes
Evaluation Count:582
no
Evaluation Count:0
0-582
2175 while(--bxe > bx && !*bxe)
evaluated: --bxe > bx
TRUEFALSE
yes
Evaluation Count:1603
yes
Evaluation Count:582
partially evaluated: !*bxe
TRUEFALSE
yes
Evaluation Count:1603
no
Evaluation Count:0
0-1603
2176 --n;
executed: --n;
Execution Count:1603
1603
2177 b->wds = n;
executed (the execution status of this line is deduced): b->wds = n;
-
2178 }
executed: }
Execution Count:582
582
2179 }
executed: }
Execution Count:582
582
2180 return q;
executed: return q;
Execution Count:120577
120577
2181} -
2182 -
2183/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. -
2184 * -
2185 * Inspired by "How to Print Floating-Point Numbers Accurately" by -
2186 * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 92-101]. -
2187 * -
2188 * Modifications: -
2189 * 1. Rather than iterating, we use a simple numeric overestimate -
2190 * to determine k = floor(log10(d)). We scale relevant -
2191 * quantities using O(log2(k)) rather than O(k) multiplications. -
2192 * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't -
2193 * try to generate digits strictly left to right. Instead, we -
2194 * compute with fewer bits and propagate the carry if necessary -
2195 * when rounding the final digit up. This is often faster. -
2196 * 3. Under the assumption that input will be rounded nearest, -
2197 * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. -
2198 * That is, we allow equality in stopping tests when the -
2199 * round-nearest rule will give the same floating-point value -
2200 * as would satisfaction of the stopping test with strict -
2201 * inequality. -
2202 * 4. We remove common factors of powers of 2 from relevant -
2203 * quantities. -
2204 * 5. When converting floating-point integers less than 1e16, -
2205 * we use floating-point arithmetic rather than resorting -
2206 * to multiple-precision integers. -
2207 * 6. When asked to produce fewer than 15 digits, we first try -
2208 * to get by with floating-point arithmetic; we resort to -
2209 * multiple-precision integer arithmetic only if we cannot -
2210 * guarantee that the floating-point calculation has given -
2211 * the correctly rounded result. For k requested digits and -
2212 * "uniformly" distributed input, the probability is -
2213 * something like 10^(k-15) that we must resort to the Long -
2214 * calculation. -
2215 */ -
2216 -
2217#if defined(Q_OS_WIN) && defined (Q_CC_GNU) && !defined(_clear87) // See QTBUG-7576 -
2218extern "C" { -
2219__attribute__ ((dllimport)) unsigned int __cdecl __MINGW_NOTHROW _control87 (unsigned int unNew, unsigned int unMask); -
2220__attribute__ ((dllimport)) unsigned int __cdecl __MINGW_NOTHROW _clearfp (void); /* Clear the FPU status word */ -
2221} -
2222# define _clear87 _clearfp -
2223#endif -
2224 -
2225/* This actually sometimes returns a pointer to a string literal -
2226 cast to a char*. Do NOT try to modify the return value. */ -
2227 -
2228Q_CORE_EXPORT char *qdtoa ( double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp) -
2229{ -
2230 // Some values of the floating-point control word can cause _qdtoa to crash with an underflow. -
2231 // We set a safe value here. -
2232#ifdef Q_OS_WIN -
2233 _clear87(); -
2234 unsigned int oldbits = _control87(0, 0); -
2235#ifndef MCW_EM -
2236# ifdef _MCW_EM -
2237# define MCW_EM _MCW_EM -
2238# else -
2239# define MCW_EM 0x0008001F -
2240# endif -
2241#endif -
2242 _control87(MCW_EM, MCW_EM); -
2243#endif -
2244 -
2245#if defined(Q_OS_LINUX) && !defined(__UCLIBC__) -
2246 fenv_t envp;
executed (the execution status of this line is deduced): fenv_t envp;
-
2247 feholdexcept(&envp);
executed (the execution status of this line is deduced): feholdexcept(&envp);
-
2248#endif -
2249 -
2250 char *s = _qdtoa(d, mode, ndigits, decpt, sign, rve, resultp);
executed (the execution status of this line is deduced): char *s = _qdtoa(d, mode, ndigits, decpt, sign, rve, resultp);
-
2251 -
2252#ifdef Q_OS_WIN -
2253 _clear87(); -
2254#ifndef _M_X64 -
2255 _control87(oldbits, 0xFFFFF); -
2256#else -
2257# ifndef _MCW_EM // Potentially missing on MinGW -
2258# define _MCW_EM 0x0008001f -
2259# endif -
2260# ifndef _MCW_RC -
2261# define _MCW_RC 0x00000300 -
2262# endif -
2263# ifndef _MCW_DN -
2264# define _MCW_DN 0x03000000 -
2265# endif -
2266 _control87(oldbits, _MCW_EM|_MCW_DN|_MCW_RC); -
2267#endif //_M_X64 -
2268#endif //Q_OS_WIN -
2269 -
2270#if defined(Q_OS_LINUX) && !defined(__UCLIBC__) -
2271 fesetenv(&envp);
executed (the execution status of this line is deduced): fesetenv(&envp);
-
2272#endif -
2273 -
2274 return s;
executed: return s;
Execution Count:1505278
1505278
2275} -
2276 -
2277static char *_qdtoa( NEEDS_VOLATILE double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp) -
2278{ -
2279 /* -
2280 Arguments ndigits, decpt, sign are similar to those -
2281 of ecvt and fcvt; trailing zeros are suppressed from -
2282 the returned string. If not null, *rve is set to point -
2283 to the end of the return value. If d is +-Infinity or NaN, -
2284 then *decpt is set to 9999. -
2285 -
2286 mode: -
2287 0 ==> shortest string that yields d when read in -
2288 and rounded to nearest. -
2289 1 ==> like 0, but with Steele & White stopping rule; -
2290 e.g. with IEEE P754 arithmetic , mode 0 gives -
2291 1e23 whereas mode 1 gives 9.999999999999999e22. -
2292 2 ==> max(1,ndigits) significant digits. This gives a -
2293 return value similar to that of ecvt, except -
2294 that trailing zeros are suppressed. -
2295 3 ==> through ndigits past the decimal point. This -
2296 gives a return value similar to that from fcvt, -
2297 except that trailing zeros are suppressed, and -
2298 ndigits can be negative. -
2299 4-9 should give the same return values as 2-3, i.e., -
2300 4 <= mode <= 9 ==> same return as mode -
2301 2 + (mode & 1). These modes are mainly for -
2302 debugging; often they run slower but sometimes -
2303 faster than modes 2-3. -
2304 4,5,8,9 ==> left-to-right digit generation. -
2305 6-9 ==> don't try fast floating-point estimate -
2306 (if applicable). -
2307 -
2308 Values of mode other than 0-9 are treated as mode 0. -
2309 -
2310 Sufficient space is allocated to the return value -
2311 to hold the suppressed trailing zeros. -
2312 */ -
2313 -
2314 int bbits, b2, b5, be, dig, i, ieps, ilim0,
executed (the execution status of this line is deduced): int bbits, b2, b5, be, dig, i, ieps, ilim0,
-
2315 j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
executed (the execution status of this line is deduced): j, j1, k, k0, k_check, leftright, m2, m5, s2, s5,
-
2316 try_quick;
executed (the execution status of this line is deduced): try_quick;
-
2317 int ilim = 0, ilim1 = 0, spec_case = 0; /* pacify gcc */
executed (the execution status of this line is deduced): int ilim = 0, ilim1 = 0, spec_case = 0;
-
2318 Long L;
executed (the execution status of this line is deduced): qint32 L;
-
2319#ifndef Sudden_Underflow -
2320 int denorm;
executed (the execution status of this line is deduced): int denorm;
-
2321 ULong x;
executed (the execution status of this line is deduced): quint32 x;
-
2322#endif -
2323 Bigint *b, *b1, *delta, *mhi, *S;
executed (the execution status of this line is deduced): Bigint *b, *b1, *delta, *mhi, *S;
-
2324 Bigint *mlo = NULL; /* pacify gcc */
executed (the execution status of this line is deduced): Bigint *mlo = __null;
-
2325 double d2;
executed (the execution status of this line is deduced): double d2;
-
2326 double ds, eps;
executed (the execution status of this line is deduced): double ds, eps;
-
2327 char *s, *s0;
executed (the execution status of this line is deduced): char *s, *s0;
-
2328 -
2329 if (getWord0(d) & Sign_bit) {
evaluated: getWord0(d) & 0x80000000
TRUEFALSE
yes
Evaluation Count:474215
yes
Evaluation Count:1031063
474215-1031063
2330 /* set sign for everything, including 0's and NaNs */ -
2331 *sign = 1;
executed (the execution status of this line is deduced): *sign = 1;
-
2332 setWord0(&d, getWord0(d) & ~Sign_bit); /* clear sign bit */
executed (the execution status of this line is deduced): setWord0(&d, getWord0(d) & ~0x80000000);
-
2333 }
executed: }
Execution Count:474215
474215
2334 else -
2335 *sign = 0;
executed: *sign = 0;
Execution Count:1031063
1031063
2336 -
2337#if defined(IEEE_Arith) + defined(VAX) -
2338#ifdef IEEE_Arith -
2339 if ((getWord0(d) & Exp_mask) == Exp_mask)
partially evaluated: (getWord0(d) & 0x7ff00000) == 0x7ff00000
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1505278
0-1505278
2340#else -
2341 if (getWord0(d) == 0x8000) -
2342#endif -
2343 { -
2344 /* Infinity or NaN */ -
2345 *decpt = 9999;
never executed (the execution status of this line is deduced): *decpt = 9999;
-
2346 s =
never executed (the execution status of this line is deduced): s =
-
2347#ifdef IEEE_Arith
never executed (the execution status of this line is deduced):
-
2348 !getWord1(d) && !(getWord0(d) & 0xfffff) ? const_cast<char*>("Infinity") :
never evaluated: !getWord1(d)
never evaluated: !(getWord0(d) & 0xfffff)
0
2349#endif
never executed (the execution status of this line is deduced):
-
2350 const_cast<char*>("NaN");
never executed (the execution status of this line is deduced): const_cast<char*>("NaN");
-
2351 if (rve)
never evaluated: rve
0
2352 *rve =
never executed: *rve = s[3] ? s + 8 : s + 3;
0
2353#ifdef IEEE_Arith
never executed: *rve = s[3] ? s + 8 : s + 3;
0
2354 s[3] ? s + 8 :
never executed: *rve = s[3] ? s + 8 : s + 3;
never evaluated: s[3]
0
2355#endif
never executed: *rve = s[3] ? s + 8 : s + 3;
0
2356 s + 3;
never executed: *rve = s[3] ? s + 8 : s + 3;
0
2357 return s;
never executed: return s;
0
2358 } -
2359#endif -
2360#ifdef IBM -
2361 d += 0; /* normalize */ -
2362#endif -
2363 if (d == g_double_zero)
evaluated: d == g_double_zero
TRUEFALSE
yes
Evaluation Count:42177
yes
Evaluation Count:1463101
42177-1463101
2364 { -
2365 *decpt = 1;
executed (the execution status of this line is deduced): *decpt = 1;
-
2366 s = const_cast<char*>("0");
executed (the execution status of this line is deduced): s = const_cast<char*>("0");
-
2367 if (rve)
partially evaluated: rve
TRUEFALSE
yes
Evaluation Count:42177
no
Evaluation Count:0
0-42177
2368 *rve = s + 1;
executed: *rve = s + 1;
Execution Count:42177
42177
2369 return s;
executed: return s;
Execution Count:42177
42177
2370 } -
2371 -
2372 b = d2b(d, &be, &bbits);
executed (the execution status of this line is deduced): b = d2b(d, &be, &bbits);
-
2373#ifdef Sudden_Underflow -
2374 i = (int)(getWord0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); -
2375#else -
2376 if ((i = int(getWord0(d) >> Exp_shift1 & (Exp_mask>>Exp_shift1))) != 0) {
evaluated: (i = int(getWord0(d) >> 20 & (0x7ff00000>>20))) != 0
TRUEFALSE
yes
Evaluation Count:1463091
yes
Evaluation Count:10
10-1463091
2377#endif -
2378 d2 = d;
executed (the execution status of this line is deduced): d2 = d;
-
2379 setWord0(&d2, getWord0(d2) & Frac_mask1);
executed (the execution status of this line is deduced): setWord0(&d2, getWord0(d2) & 0xfffff);
-
2380 setWord0(&d2, getWord0(d2) | Exp_11);
executed (the execution status of this line is deduced): setWord0(&d2, getWord0(d2) | 0x3ff00000);
-
2381#ifdef IBM -
2382 if (j = 11 - hi0bits(getWord0(d2) & Frac_mask)) -
2383 d2 /= 1 << j; -
2384#endif -
2385 -
2386 /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 -
2387 * log10(x) = log(x) / log(10) -
2388 * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) -
2389 * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) -
2390 * -
2391 * This suggests computing an approximation k to log10(d) by -
2392 * -
2393 * k = (i - Bias)*0.301029995663981 -
2394 * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); -
2395 * -
2396 * We want k to be too large rather than too small. -
2397 * The error in the first-order Taylor series approximation -
2398 * is in our favor, so we just round up the constant enough -
2399 * to compensate for any error in the multiplication of -
2400 * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, -
2401 * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, -
2402 * adding 1e-13 to the constant term more than suffices. -
2403 * Hence we adjust the constant term to 0.1760912590558. -
2404 * (We could get a more accurate k by invoking log10, -
2405 * but this is probably not worthwhile.) -
2406 */ -
2407 -
2408 i -= Bias;
executed (the execution status of this line is deduced): i -= 1023;
-
2409#ifdef IBM -
2410 i <<= 2; -
2411 i += j; -
2412#endif -
2413#ifndef Sudden_Underflow -
2414 denorm = 0;
executed (the execution status of this line is deduced): denorm = 0;
-
2415 }
executed: }
Execution Count:1463091
1463091
2416 else { -
2417 /* d is denormalized */ -
2418 -
2419 i = bbits + be + (Bias + (P-1) - 1);
executed (the execution status of this line is deduced): i = bbits + be + (1023 + (53 -1) - 1);
-
2420 x = i > 32 ? getWord0(d) << (64 - i) | getWord1(d) >> (i - 32)
partially evaluated: i > 32
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
2421 : getWord1(d) << (32 - i);
executed (the execution status of this line is deduced): : getWord1(d) << (32 - i);
-
2422 d2 = x;
executed (the execution status of this line is deduced): d2 = x;
-
2423 setWord0(&d2, getWord0(d2) - 31*Exp_msk1); /* adjust exponent */
executed (the execution status of this line is deduced): setWord0(&d2, getWord0(d2) - 31*0x100000);
-
2424 i -= (Bias + (P-1) - 1) + 1;
executed (the execution status of this line is deduced): i -= (1023 + (53 -1) - 1) + 1;
-
2425 denorm = 1;
executed (the execution status of this line is deduced): denorm = 1;
-
2426 }
executed: }
Execution Count:10
10
2427#endif -
2428 ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
executed (the execution status of this line is deduced): ds = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981;
-
2429 k = int(ds);
executed (the execution status of this line is deduced): k = int(ds);
-
2430 if (ds < 0. && ds != k)
evaluated: ds < 0.
TRUEFALSE
yes
Evaluation Count:49667
yes
Evaluation Count:1413434
partially evaluated: ds != k
TRUEFALSE
yes
Evaluation Count:49667
no
Evaluation Count:0
0-1413434
2431 k--; /* want k = floor(ds) */
executed: k--;
Execution Count:49667
49667
2432 k_check = 1;
executed (the execution status of this line is deduced): k_check = 1;
-
2433 if (k >= 0 && k <= Ten_pmax) {
evaluated: k >= 0
TRUEFALSE
yes
Evaluation Count:1413434
yes
Evaluation Count:49667
evaluated: k <= 22
TRUEFALSE
yes
Evaluation Count:1410332
yes
Evaluation Count:3102
3102-1413434
2434 if (d < tens[k])
evaluated: d < tens[k]
TRUEFALSE
yes
Evaluation Count:6950
yes
Evaluation Count:1403382
6950-1403382
2435 k--;
executed: k--;
Execution Count:6950
6950
2436 k_check = 0;
executed (the execution status of this line is deduced): k_check = 0;
-
2437 }
executed: }
Execution Count:1410332
1410332
2438 j = bbits - i - 1;
executed (the execution status of this line is deduced): j = bbits - i - 1;
-
2439 if (j >= 0) {
evaluated: j >= 0
TRUEFALSE
yes
Evaluation Count:662974
yes
Evaluation Count:800127
662974-800127
2440 b2 = 0;
executed (the execution status of this line is deduced): b2 = 0;
-
2441 s2 = j;
executed (the execution status of this line is deduced): s2 = j;
-
2442 }
executed: }
Execution Count:662974
662974
2443 else { -
2444 b2 = -j;
executed (the execution status of this line is deduced): b2 = -j;
-
2445 s2 = 0;
executed (the execution status of this line is deduced): s2 = 0;
-
2446 }
executed: }
Execution Count:800127
800127
2447 if (k >= 0) {
evaluated: k >= 0
TRUEFALSE
yes
Evaluation Count:1410310
yes
Evaluation Count:52791
52791-1410310
2448 b5 = 0;
executed (the execution status of this line is deduced): b5 = 0;
-
2449 s5 = k;
executed (the execution status of this line is deduced): s5 = k;
-
2450 s2 += k;
executed (the execution status of this line is deduced): s2 += k;
-
2451 }
executed: }
Execution Count:1410310
1410310
2452 else { -
2453 b2 -= k;
executed (the execution status of this line is deduced): b2 -= k;
-
2454 b5 = -k;
executed (the execution status of this line is deduced): b5 = -k;
-
2455 s5 = 0;
executed (the execution status of this line is deduced): s5 = 0;
-
2456 }
executed: }
Execution Count:52791
52791
2457 if (mode < 0 || mode > 9)
partially evaluated: mode < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1463101
partially evaluated: mode > 9
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1463101
0-1463101
2458 mode = 0;
never executed: mode = 0;
0
2459 try_quick = 1;
executed (the execution status of this line is deduced): try_quick = 1;
-
2460 if (mode > 5) {
partially evaluated: mode > 5
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1463101
0-1463101
2461 mode -= 4;
never executed (the execution status of this line is deduced): mode -= 4;
-
2462 try_quick = 0;
never executed (the execution status of this line is deduced): try_quick = 0;
-
2463 }
never executed: }
0
2464 leftright = 1;
executed (the execution status of this line is deduced): leftright = 1;
-
2465 switch(mode) { -
2466 case 0: -
2467 case 1: -
2468 ilim = ilim1 = -1;
never executed (the execution status of this line is deduced): ilim = ilim1 = -1;
-
2469 i = 18;
never executed (the execution status of this line is deduced): i = 18;
-
2470 ndigits = 0;
never executed (the execution status of this line is deduced): ndigits = 0;
-
2471 break;
never executed: break;
0
2472 case 2: -
2473 leftright = 0;
executed (the execution status of this line is deduced): leftright = 0;
-
2474 /* no break */ -
2475 case 4:
code before this statement executed: case 4:
Execution Count:1461963
1461963
2476 if (ndigits <= 0)
evaluated: ndigits <= 0
TRUEFALSE
yes
Evaluation Count:1681
yes
Evaluation Count:1460282
1681-1460282
2477 ndigits = 1;
executed: ndigits = 1;
Execution Count:1681
1681
2478 ilim = ilim1 = i = ndigits;
executed (the execution status of this line is deduced): ilim = ilim1 = i = ndigits;
-
2479 break;
executed: break;
Execution Count:1461963
1461963
2480 case 3: -
2481 leftright = 0;
executed (the execution status of this line is deduced): leftright = 0;
-
2482 /* no break */ -
2483 case 5:
code before this statement executed: case 5:
Execution Count:1138
1138
2484 i = ndigits + k + 1;
executed (the execution status of this line is deduced): i = ndigits + k + 1;
-
2485 ilim = i;
executed (the execution status of this line is deduced): ilim = i;
-
2486 ilim1 = i - 1;
executed (the execution status of this line is deduced): ilim1 = i - 1;
-
2487 if (i <= 0)
evaluated: i <= 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1135
3-1135
2488 i = 1;
executed: i = 1;
Execution Count:3
3
2489 }
executed: }
Execution Count:1138
1138
2490 QT_TRY { -
2491 *resultp = static_cast<char *>(malloc(i + 1));
executed (the execution status of this line is deduced): *resultp = static_cast<char *>(malloc(i + 1));
-
2492 Q_CHECK_PTR(*resultp);
never executed: qBadAlloc();
executed: }
Execution Count:1463101
partially evaluated: !(*resultp)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1463101
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1463101
0-1463101
2493 } QT_CATCH(...) {
executed: }
Execution Count:1463101
1463101
2494 Bfree(b);
never executed (the execution status of this line is deduced): Bfree(b);
-
2495 QT_RETHROW;
never executed: throw;
0
2496 } -
2497 s = s0 = *resultp;
executed (the execution status of this line is deduced): s = s0 = *resultp;
-
2498 -
2499 if (ilim >= 0 && ilim <= Quick_max && try_quick) {
partially evaluated: ilim >= 0
TRUEFALSE
yes
Evaluation Count:1463101
no
Evaluation Count:0
evaluated: ilim <= 14
TRUEFALSE
yes
Evaluation Count:1460594
yes
Evaluation Count:2507
partially evaluated: try_quick
TRUEFALSE
yes
Evaluation Count:1460594
no
Evaluation Count:0
0-1463101
2500 -
2501 /* Try to get by with floating-point arithmetic. */ -
2502 -
2503 i = 0;
executed (the execution status of this line is deduced): i = 0;
-
2504 d2 = d;
executed (the execution status of this line is deduced): d2 = d;
-
2505 k0 = k;
executed (the execution status of this line is deduced): k0 = k;
-
2506 ilim0 = ilim;
executed (the execution status of this line is deduced): ilim0 = ilim;
-
2507 ieps = 2; /* conservative */
executed (the execution status of this line is deduced): ieps = 2;
-
2508 if (k > 0) {
evaluated: k > 0
TRUEFALSE
yes
Evaluation Count:1330446
yes
Evaluation Count:130148
130148-1330446
2509 ds = tens[k&0xf];
executed (the execution status of this line is deduced): ds = tens[k&0xf];
-
2510 j = k >> 4;
executed (the execution status of this line is deduced): j = k >> 4;
-
2511 if (j & Bletch) {
evaluated: j & 0x10
TRUEFALSE
yes
Evaluation Count:223
yes
Evaluation Count:1330223
223-1330223
2512 /* prevent overflows */ -
2513 j &= Bletch - 1;
executed (the execution status of this line is deduced): j &= 0x10 - 1;
-
2514 d /= bigtens[n_bigtens-1];
executed (the execution status of this line is deduced): d /= bigtens[5 -1];
-
2515 ieps++;
executed (the execution status of this line is deduced): ieps++;
-
2516 }
executed: }
Execution Count:223
223
2517 for(; j; j >>= 1, i++)
evaluated: j
TRUEFALSE
yes
Evaluation Count:6799
yes
Evaluation Count:1330446
6799-1330446
2518 if (j & 1) {
evaluated: j & 1
TRUEFALSE
yes
Evaluation Count:3639
yes
Evaluation Count:3160
3160-3639
2519 ieps++;
executed (the execution status of this line is deduced): ieps++;
-
2520 ds *= bigtens[i];
executed (the execution status of this line is deduced): ds *= bigtens[i];
-
2521 }
executed: }
Execution Count:3639
3639
2522 d /= ds;
executed (the execution status of this line is deduced): d /= ds;
-
2523 }
executed: }
Execution Count:1330446
1330446
2524 else if ((j1 = -k) != 0) {
evaluated: (j1 = -k) != 0
TRUEFALSE
yes
Evaluation Count:51632
yes
Evaluation Count:78516
51632-78516
2525 d *= tens[j1 & 0xf];
executed (the execution status of this line is deduced): d *= tens[j1 & 0xf];
-
2526 for(j = j1 >> 4; j; j >>= 1, i++)
evaluated: j
TRUEFALSE
yes
Evaluation Count:3890
yes
Evaluation Count:51632
3890-51632
2527 if (j & 1) {
evaluated: j & 1
TRUEFALSE
yes
Evaluation Count:2526
yes
Evaluation Count:1364
1364-2526
2528 ieps++;
executed (the execution status of this line is deduced): ieps++;
-
2529 d *= bigtens[i];
executed (the execution status of this line is deduced): d *= bigtens[i];
-
2530 }
executed: }
Execution Count:2526
2526
2531 }
executed: }
Execution Count:51632
51632
2532 if (k_check && d < 1. && ilim > 0) {
evaluated: k_check
TRUEFALSE
yes
Evaluation Count:51221
yes
Evaluation Count:1409373
evaluated: d < 1.
TRUEFALSE
yes
Evaluation Count:3920
yes
Evaluation Count:47301
partially evaluated: ilim > 0
TRUEFALSE
yes
Evaluation Count:3920
no
Evaluation Count:0
0-1409373
2533 if (ilim1 <= 0)
partially evaluated: ilim1 <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3920
0-3920
2534 goto fast_failed;
never executed: goto fast_failed;
0
2535 ilim = ilim1;
executed (the execution status of this line is deduced): ilim = ilim1;
-
2536 k--;
executed (the execution status of this line is deduced): k--;
-
2537 d *= 10.;
executed (the execution status of this line is deduced): d *= 10.;
-
2538 ieps++;
executed (the execution status of this line is deduced): ieps++;
-
2539 }
executed: }
Execution Count:3920
3920
2540 eps = ieps*d + 7.;
executed (the execution status of this line is deduced): eps = ieps*d + 7.;
-
2541 setWord0(&eps, getWord0(eps) - (P-1)*Exp_msk1);
executed (the execution status of this line is deduced): setWord0(&eps, getWord0(eps) - (53 -1)*0x100000);
-
2542 if (ilim == 0) {
evaluated: ilim == 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1460591
3-1460591
2543 S = mhi = 0;
executed (the execution status of this line is deduced): S = mhi = 0;
-
2544 d -= 5.;
executed (the execution status of this line is deduced): d -= 5.;
-
2545 if (d > eps)
partially evaluated: d > eps
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2546 goto one_digit;
never executed: goto one_digit;
0
2547 if (d < -eps)
evaluated: d < -eps
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
2548 goto no_digits;
executed: goto no_digits;
Execution Count:2
2
2549 goto fast_failed;
executed: goto fast_failed;
Execution Count:1
1
2550 } -
2551#ifndef No_leftright -
2552 if (leftright) {
partially evaluated: leftright
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1460591
0-1460591
2553 /* Use Steele & White method of only -
2554 * generating digits needed. -
2555 */ -
2556 eps = 0.5/tens[ilim-1] - eps;
never executed (the execution status of this line is deduced): eps = 0.5/tens[ilim-1] - eps;
-
2557 for(i = 0;;) {
never executed (the execution status of this line is deduced): for(i = 0;;) {
-
2558 L = Long(d);
never executed (the execution status of this line is deduced): L = qint32(d);
-
2559 d -= L;
never executed (the execution status of this line is deduced): d -= L;
-
2560 *s++ = '0' + int(L);
never executed (the execution status of this line is deduced): *s++ = '0' + int(L);
-
2561 if (d < eps)
never evaluated: d < eps
0
2562 goto ret1;
never executed: goto ret1;
0
2563 if (1. - d < eps)
never evaluated: 1. - d < eps
0
2564 goto bump_up;
never executed: goto bump_up;
0
2565 if (++i >= ilim)
never evaluated: ++i >= ilim
0
2566 break;
never executed: break;
0
2567 eps *= 10.;
never executed (the execution status of this line is deduced): eps *= 10.;
-
2568 d *= 10.;
never executed (the execution status of this line is deduced): d *= 10.;
-
2569 }
never executed: }
0
2570 }
never executed: }
0
2571 else { -
2572#endif -
2573 /* Generate ilim digits, then fix them up. */ -
2574#if defined(Q_OS_IRIX) && defined(Q_CC_GNU) -
2575 // work around a bug on 64 bit IRIX gcc -
2576 double *t = (double *) tens; -
2577 eps *= t[ilim-1]; -
2578#else -
2579 eps *= tens[ilim-1];
executed (the execution status of this line is deduced): eps *= tens[ilim-1];
-
2580#endif -
2581 for(i = 1;; i++, d *= 10.) {
executed (the execution status of this line is deduced): for(i = 1;; i++, d *= 10.) {
-
2582 L = Long(d);
executed (the execution status of this line is deduced): L = qint32(d);
-
2583 d -= L;
executed (the execution status of this line is deduced): d -= L;
-
2584 *s++ = '0' + int(L);
executed (the execution status of this line is deduced): *s++ = '0' + int(L);
-
2585 if (i == ilim) {
evaluated: i == ilim
TRUEFALSE
yes
Evaluation Count:1460591
yes
Evaluation Count:7279600
1460591-7279600
2586 if (d > 0.5 + eps)
evaluated: d > 0.5 + eps
TRUEFALSE
yes
Evaluation Count:422158
yes
Evaluation Count:1038433
422158-1038433
2587 goto bump_up;
executed: goto bump_up;
Execution Count:422158
422158
2588 else if (d < 0.5 - eps) {
evaluated: d < 0.5 - eps
TRUEFALSE
yes
Evaluation Count:1038429
yes
Evaluation Count:4
4-1038429
2589 while(*--s == '0') {}
executed: }
Execution Count:3900020
evaluated: *--s == '0'
TRUEFALSE
yes
Evaluation Count:3900020
yes
Evaluation Count:1038429
1038429-3900020
2590 s++;
executed (the execution status of this line is deduced): s++;
-
2591 goto ret1;
executed: goto ret1;
Execution Count:1038429
1038429
2592 } -
2593 break;
executed: break;
Execution Count:4
4
2594 } -
2595 }
executed: }
Execution Count:7279600
7279600
2596#ifndef No_leftright -
2597 }
executed: }
Execution Count:4
4
2598#endif -
2599 fast_failed:
code before this statement executed: fast_failed:
Execution Count:4
4
2600 s = s0;
executed (the execution status of this line is deduced): s = s0;
-
2601 d = d2;
executed (the execution status of this line is deduced): d = d2;
-
2602 k = k0;
executed (the execution status of this line is deduced): k = k0;
-
2603 ilim = ilim0;
executed (the execution status of this line is deduced): ilim = ilim0;
-
2604 }
executed: }
Execution Count:5
5
2605 -
2606 /* Do we have a "small" integer? */ -
2607 -
2608 if (be >= 0 && k <= Int_max) {
evaluated: be >= 0
TRUEFALSE
yes
Evaluation Count:735
yes
Evaluation Count:1777
evaluated: k <= 14
TRUEFALSE
yes
Evaluation Count:282
yes
Evaluation Count:453
282-1777
2609 /* Yes. */ -
2610 ds = tens[k];
executed (the execution status of this line is deduced): ds = tens[k];
-
2611 if (ndigits < 0 && ilim <= 0) {
partially evaluated: ndigits < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:282
never evaluated: ilim <= 0
0-282
2612 S = mhi = 0;
never executed (the execution status of this line is deduced): S = mhi = 0;
-
2613 if (ilim < 0 || d <= 5*ds)
never evaluated: ilim < 0
never evaluated: d <= 5*ds
0
2614 goto no_digits;
never executed: goto no_digits;
0
2615 goto one_digit;
never executed: goto one_digit;
0
2616 } -
2617 for(i = 1;; i++) {
executed (the execution status of this line is deduced): for(i = 1;; i++) {
-
2618 L = Long(d / ds);
executed (the execution status of this line is deduced): L = qint32(d / ds);
-
2619 d -= L*ds;
executed (the execution status of this line is deduced): d -= L*ds;
-
2620#ifdef Check_FLT_ROUNDS -
2621 /* If FLT_ROUNDS == 2, L will usually be high by 1 */ -
2622 if (d < 0) { -
2623 L--; -
2624 d += ds; -
2625 } -
2626#endif -
2627 *s++ = '0' + int(L);
executed (the execution status of this line is deduced): *s++ = '0' + int(L);
-
2628 if (i == ilim) {
partially evaluated: i == ilim
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:331
0-331
2629 d += d;
never executed (the execution status of this line is deduced): d += d;
-
2630 if (d > ds || (d == ds && L & 1)) {
never evaluated: d > ds
never evaluated: d == ds
never evaluated: L & 1
0
2631 bump_up: -
2632 while(*--s == '9')
evaluated: *--s == '9'
TRUEFALSE
yes
Evaluation Count:1233417
yes
Evaluation Count:418602
418602-1233417
2633 if (s == s0) {
evaluated: s == s0
TRUEFALSE
yes
Evaluation Count:3556
yes
Evaluation Count:1229861
3556-1229861
2634 k++;
executed (the execution status of this line is deduced): k++;
-
2635 *s = '0';
executed (the execution status of this line is deduced): *s = '0';
-
2636 break;
executed: break;
Execution Count:3556
3556
2637 } -
2638 ++*s++;
executed (the execution status of this line is deduced): ++*s++;
-
2639 }
executed: }
Execution Count:422158
422158
2640 break;
executed: break;
Execution Count:422158
422158
2641 } -
2642 if ((d *= 10.) == g_double_zero)
evaluated: (d *= 10.) == g_double_zero
TRUEFALSE
yes
Evaluation Count:282
yes
Evaluation Count:49
49-282
2643 break;
executed: break;
Execution Count:282
282
2644 }
executed: }
Execution Count:49
49
2645 goto ret1;
executed: goto ret1;
Execution Count:422440
422440
2646 } -
2647 -
2648 m2 = b2;
executed (the execution status of this line is deduced): m2 = b2;
-
2649 m5 = b5;
executed (the execution status of this line is deduced): m5 = b5;
-
2650 mhi = mlo = 0;
executed (the execution status of this line is deduced): mhi = mlo = 0;
-
2651 if (leftright) {
partially evaluated: leftright
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2230
0-2230
2652 if (mode < 2) {
never evaluated: mode < 2
0
2653 i =
never executed (the execution status of this line is deduced): i =
-
2654#ifndef Sudden_Underflow
never executed (the execution status of this line is deduced):
-
2655 denorm ? be + (Bias + (P-1) - 1 + 1) :
never evaluated: denorm
0
2656#endif
never executed (the execution status of this line is deduced):
-
2657#ifdef IBM
never executed (the execution status of this line is deduced):
-
2658 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3);
never executed (the execution status of this line is deduced):
-
2659#else
never executed (the execution status of this line is deduced):
-
2660 1 + P - bbits;
never executed (the execution status of this line is deduced): 1 + 53 - bbits;
-
2661#endif -
2662 }
never executed: }
0
2663 else { -
2664 j = ilim - 1;
never executed (the execution status of this line is deduced): j = ilim - 1;
-
2665 if (m5 >= j)
never evaluated: m5 >= j
0
2666 m5 -= j;
never executed: m5 -= j;
0
2667 else { -
2668 s5 += j -= m5;
never executed (the execution status of this line is deduced): s5 += j -= m5;
-
2669 b5 += j;
never executed (the execution status of this line is deduced): b5 += j;
-
2670 m5 = 0;
never executed (the execution status of this line is deduced): m5 = 0;
-
2671 }
never executed: }
0
2672 if ((i = ilim) < 0) {
never evaluated: (i = ilim) < 0
0
2673 m2 -= i;
never executed (the execution status of this line is deduced): m2 -= i;
-
2674 i = 0;
never executed (the execution status of this line is deduced): i = 0;
-
2675 }
never executed: }
0
2676 }
never executed: }
0
2677 b2 += i;
never executed (the execution status of this line is deduced): b2 += i;
-
2678 s2 += i;
never executed (the execution status of this line is deduced): s2 += i;
-
2679 mhi = i2b(1);
never executed (the execution status of this line is deduced): mhi = i2b(1);
-
2680 }
never executed: }
0
2681 if (m2 > 0 && s2 > 0) {
evaluated: m2 > 0
TRUEFALSE
yes
Evaluation Count:1613
yes
Evaluation Count:617
partially evaluated: s2 > 0
TRUEFALSE
yes
Evaluation Count:1613
no
Evaluation Count:0
0-1613
2682 i = m2 < s2 ? m2 : s2;
evaluated: m2 < s2
TRUEFALSE
yes
Evaluation Count:1160
yes
Evaluation Count:453
453-1160
2683 b2 -= i;
executed (the execution status of this line is deduced): b2 -= i;
-
2684 m2 -= i;
executed (the execution status of this line is deduced): m2 -= i;
-
2685 s2 -= i;
executed (the execution status of this line is deduced): s2 -= i;
-
2686 }
executed: }
Execution Count:1613
1613
2687 if (b5 > 0) {
evaluated: b5 > 0
TRUEFALSE
yes
Evaluation Count:1160
yes
Evaluation Count:1070
1070-1160
2688 if (leftright) {
partially evaluated: leftright
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1160
0-1160
2689 if (m5 > 0) {
never evaluated: m5 > 0
0
2690 mhi = pow5mult(mhi, m5);
never executed (the execution status of this line is deduced): mhi = pow5mult(mhi, m5);
-
2691 b1 = mult(mhi, b);
never executed (the execution status of this line is deduced): b1 = mult(mhi, b);
-
2692 Bfree(b);
never executed (the execution status of this line is deduced): Bfree(b);
-
2693 b = b1;
never executed (the execution status of this line is deduced): b = b1;
-
2694 }
never executed: }
0
2695 if ((j = b5 - m5) != 0)
never evaluated: (j = b5 - m5) != 0
0
2696 b = pow5mult(b, j);
never executed: b = pow5mult(b, j);
0
2697 }
never executed: }
0
2698 else -
2699 b = pow5mult(b, b5);
executed: b = pow5mult(b, b5);
Execution Count:1160
1160
2700 } -
2701 S = i2b(1);
executed (the execution status of this line is deduced): S = i2b(1);
-
2702 if (s5 > 0)
evaluated: s5 > 0
TRUEFALSE
yes
Evaluation Count:619
yes
Evaluation Count:1611
619-1611
2703 S = pow5mult(S, s5);
executed: S = pow5mult(S, s5);
Execution Count:619
619
2704 -
2705 /* Check for special case that d is a normalized power of 2. */ -
2706 -
2707 if (mode < 2) {
partially evaluated: mode < 2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2230
0-2230
2708 if (!getWord1(d) && !(getWord0(d) & Bndry_mask)
never evaluated: !getWord1(d)
never evaluated: !(getWord0(d) & 0xfffff)
0
2709#ifndef Sudden_Underflow
never executed (the execution status of this line is deduced):
-
2710 && getWord0(d) & Exp_mask
never evaluated: getWord0(d) & 0x7ff00000
0
2711#endif -
2712 ) { -
2713 /* The special case */ -
2714 b2 += Log2P;
never executed (the execution status of this line is deduced): b2 += 1;
-
2715 s2 += Log2P;
never executed (the execution status of this line is deduced): s2 += 1;
-
2716 spec_case = 1;
never executed (the execution status of this line is deduced): spec_case = 1;
-
2717 }
never executed: }
0
2718 else -
2719 spec_case = 0;
never executed: spec_case = 0;
0
2720 } -
2721 -
2722 /* Arrange for convenient computation of quotients: -
2723 * shift left if necessary so divisor has 4 leading 0 bits. -
2724 * -
2725 * Perhaps we should just compute leading 28 bits of S once -
2726 * and for all and pass them and a shift to quorem, so it -
2727 * can do shifts and ors to compute the numerator for q. -
2728 */ -
2729#ifdef Pack_32 -
2730 if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) != 0)
partially evaluated: (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f) != 0
TRUEFALSE
yes
Evaluation Count:2230
no
Evaluation Count:0
evaluated: s5
TRUEFALSE
yes
Evaluation Count:619
yes
Evaluation Count:1611
0-2230
2731 i = 32 - i;
executed: i = 32 - i;
Execution Count:2230
2230
2732#else -
2733 if (i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf) -
2734 i = 16 - i; -
2735#endif -
2736 if (i > 4) {
evaluated: i > 4
TRUEFALSE
yes
Evaluation Count:2102
yes
Evaluation Count:128
128-2102
2737 i -= 4;
executed (the execution status of this line is deduced): i -= 4;
-
2738 b2 += i;
executed (the execution status of this line is deduced): b2 += i;
-
2739 m2 += i;
executed (the execution status of this line is deduced): m2 += i;
-
2740 s2 += i;
executed (the execution status of this line is deduced): s2 += i;
-
2741 }
executed: }
Execution Count:2102
2102
2742 else if (i < 4) {
evaluated: i < 4
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:64
64
2743 i += 28;
executed (the execution status of this line is deduced): i += 28;
-
2744 b2 += i;
executed (the execution status of this line is deduced): b2 += i;
-
2745 m2 += i;
executed (the execution status of this line is deduced): m2 += i;
-
2746 s2 += i;
executed (the execution status of this line is deduced): s2 += i;
-
2747 }
executed: }
Execution Count:64
64
2748 if (b2 > 0)
evaluated: b2 > 0
TRUEFALSE
yes
Evaluation Count:2166
yes
Evaluation Count:64
64-2166
2749 b = lshift(b, b2);
executed: b = lshift(b, b2);
Execution Count:2166
2166
2750 if (s2 > 0)
partially evaluated: s2 > 0
TRUEFALSE
yes
Evaluation Count:2230
no
Evaluation Count:0
0-2230
2751 S = lshift(S, s2);
executed: S = lshift(S, s2);
Execution Count:2230
2230
2752 if (k_check) {
evaluated: k_check
TRUEFALSE
yes
Evaluation Count:1549
yes
Evaluation Count:681
681-1549
2753 if (cmp(b,S) < 0) {
evaluated: cmp(b,S) < 0
TRUEFALSE
yes
Evaluation Count:512
yes
Evaluation Count:1037
512-1037
2754 k--;
executed (the execution status of this line is deduced): k--;
-
2755 b = multadd(b, 10, 0); /* we botched the k estimate */
executed (the execution status of this line is deduced): b = multadd(b, 10, 0);
-
2756 if (leftright)
partially evaluated: leftright
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:512
0-512
2757 mhi = multadd(mhi, 10, 0);
never executed: mhi = multadd(mhi, 10, 0);
0
2758 ilim = ilim1;
executed (the execution status of this line is deduced): ilim = ilim1;
-
2759 }
executed: }
Execution Count:512
512
2760 }
executed: }
Execution Count:1549
1549
2761 if (ilim <= 0 && mode > 2) {
evaluated: ilim <= 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2229
partially evaluated: mode > 2
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-2229
2762 if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) {
partially evaluated: ilim < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: cmp(b,S = multadd(S,5,0)) <= 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2763 /* no digits, fcvt style */ -
2764 no_digits: -
2765 k = -1 - ndigits;
executed (the execution status of this line is deduced): k = -1 - ndigits;
-
2766 goto ret;
executed: goto ret;
Execution Count:2
2
2767 } -
2768 one_digit:
code before this statement executed: one_digit:
Execution Count:1
1
2769 *s++ = '1';
executed (the execution status of this line is deduced): *s++ = '1';
-
2770 k++;
executed (the execution status of this line is deduced): k++;
-
2771 goto ret;
executed: goto ret;
Execution Count:1
1
2772 } -
2773 if (leftright) {
partially evaluated: leftright
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2229
0-2229
2774 if (m2 > 0)
never evaluated: m2 > 0
0
2775 mhi = lshift(mhi, m2);
never executed: mhi = lshift(mhi, m2);
0
2776 -
2777 /* Compute mlo -- check for special case -
2778 * that d is a normalized power of 2. -
2779 */ -
2780 -
2781 mlo = mhi;
never executed (the execution status of this line is deduced): mlo = mhi;
-
2782 if (spec_case) {
never evaluated: spec_case
0
2783 mhi = Balloc(mhi->k);
never executed (the execution status of this line is deduced): mhi = Balloc(mhi->k);
-
2784 Bcopy(mhi, mlo);
never executed (the execution status of this line is deduced): memcpy(reinterpret_cast<char *>(&mhi->sign), reinterpret_cast<char *>(&mlo->sign), mlo->wds*sizeof(qint32) + 2*sizeof(int));
-
2785 mhi = lshift(mhi, Log2P);
never executed (the execution status of this line is deduced): mhi = lshift(mhi, 1);
-
2786 }
never executed: }
0
2787 -
2788 for(i = 1;;i++) {
never executed (the execution status of this line is deduced): for(i = 1;;i++) {
-
2789 dig = quorem(b,S) + '0';
never executed (the execution status of this line is deduced): dig = quorem(b,S) + '0';
-
2790 /* Do we yet have the shortest decimal string -
2791 * that will round to d? -
2792 */ -
2793 j = cmp(b, mlo);
never executed (the execution status of this line is deduced): j = cmp(b, mlo);
-
2794 delta = diff(S, mhi);
never executed (the execution status of this line is deduced): delta = diff(S, mhi);
-
2795 j1 = delta->sign ? 1 : cmp(b, delta);
never evaluated: delta->sign
0
2796 Bfree(delta);
never executed (the execution status of this line is deduced): Bfree(delta);
-
2797#ifndef ROUND_BIASED -
2798 if (j1 == 0 && !mode && !(getWord1(d) & 1)) {
never evaluated: j1 == 0
never evaluated: !mode
never evaluated: !(getWord1(d) & 1)
0
2799 if (dig == '9')
never evaluated: dig == '9'
0
2800 goto round_9_up;
never executed: goto round_9_up;
0
2801 if (j > 0)
never evaluated: j > 0
0
2802 dig++;
never executed: dig++;
0
2803 *s++ = dig;
never executed (the execution status of this line is deduced): *s++ = dig;
-
2804 goto ret;
never executed: goto ret;
0
2805 } -
2806#endif -
2807 if (j < 0 || (j == 0 && !mode
never evaluated: j < 0
never evaluated: j == 0
never evaluated: !mode
0
2808#ifndef ROUND_BIASED
never executed (the execution status of this line is deduced):
-
2809 && !(getWord1(d) & 1)
never evaluated: !(getWord1(d) & 1)
0
2810#endif
never executed (the execution status of this line is deduced):
-
2811 )) {
never executed (the execution status of this line is deduced): )) {
-
2812 if (j1 > 0) {
never evaluated: j1 > 0
0
2813 b = lshift(b, 1);
never executed (the execution status of this line is deduced): b = lshift(b, 1);
-
2814 j1 = cmp(b, S);
never executed (the execution status of this line is deduced): j1 = cmp(b, S);
-
2815 if ((j1 > 0 || (j1 == 0 && dig & 1))
never evaluated: j1 > 0
never evaluated: j1 == 0
never evaluated: dig & 1
0
2816 && dig++ == '9')
never evaluated: dig++ == '9'
0
2817 goto round_9_up;
never executed: goto round_9_up;
0
2818 }
never executed: }
0
2819 *s++ = dig;
never executed (the execution status of this line is deduced): *s++ = dig;
-
2820 goto ret;
never executed: goto ret;
0
2821 } -
2822 if (j1 > 0) {
never evaluated: j1 > 0
0
2823 if (dig == '9') { /* possible if i == 1 */
never evaluated: dig == '9'
0
2824 round_9_up: -
2825 *s++ = '9';
never executed (the execution status of this line is deduced): *s++ = '9';
-
2826 goto roundoff;
never executed: goto roundoff;
0
2827 } -
2828 *s++ = dig + 1;
never executed (the execution status of this line is deduced): *s++ = dig + 1;
-
2829 goto ret;
never executed: goto ret;
0
2830 } -
2831 *s++ = dig;
never executed (the execution status of this line is deduced): *s++ = dig;
-
2832 if (i == ilim)
never evaluated: i == ilim
0
2833 break;
never executed: break;
0
2834 b = multadd(b, 10, 0);
never executed (the execution status of this line is deduced): b = multadd(b, 10, 0);
-
2835 if (mlo == mhi)
never evaluated: mlo == mhi
0
2836 mlo = mhi = multadd(mhi, 10, 0);
never executed: mlo = mhi = multadd(mhi, 10, 0);
0
2837 else { -
2838 mlo = multadd(mlo, 10, 0);
never executed (the execution status of this line is deduced): mlo = multadd(mlo, 10, 0);
-
2839 mhi = multadd(mhi, 10, 0);
never executed (the execution status of this line is deduced): mhi = multadd(mhi, 10, 0);
-
2840 }
never executed: }
0
2841 } -
2842 }
never executed: }
0
2843 else -
2844 for(i = 1;; i++) {
executed (the execution status of this line is deduced): for(i = 1;; i++) {
-
2845 *s++ = dig = quorem(b,S) + '0';
executed (the execution status of this line is deduced): *s++ = dig = quorem(b,S) + '0';
-
2846 if (i >= ilim)
evaluated: i >= ilim
TRUEFALSE
yes
Evaluation Count:2229
yes
Evaluation Count:122213
2229-122213
2847 break;
executed: break;
Execution Count:2229
2229
2848 b = multadd(b, 10, 0);
executed (the execution status of this line is deduced): b = multadd(b, 10, 0);
-
2849 }
executed: }
Execution Count:122213
122213
2850 -
2851 /* Round off last digit */ -
2852 -
2853 b = lshift(b, 1);
executed (the execution status of this line is deduced): b = lshift(b, 1);
-
2854 j = cmp(b, S);
executed (the execution status of this line is deduced): j = cmp(b, S);
-
2855 if (j > 0 || (j == 0 && dig & 1)) {
evaluated: j > 0
TRUEFALSE
yes
Evaluation Count:910
yes
Evaluation Count:1319
evaluated: j == 0
TRUEFALSE
yes
Evaluation Count:68
yes
Evaluation Count:1251
evaluated: dig & 1
TRUEFALSE
yes
Evaluation Count:64
yes
Evaluation Count:4
4-1319
2856 roundoff: -
2857 while(*--s == '9')
evaluated: *--s == '9'
TRUEFALSE
yes
Evaluation Count:284
yes
Evaluation Count:974
284-974
2858 if (s == s0) {
partially evaluated: s == s0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:284
0-284
2859 k++;
never executed (the execution status of this line is deduced): k++;
-
2860 *s++ = '1';
never executed (the execution status of this line is deduced): *s++ = '1';
-
2861 goto ret;
never executed: goto ret;
0
2862 } -
2863 ++*s++;
executed (the execution status of this line is deduced): ++*s++;
-
2864 }
executed: }
Execution Count:974
974
2865 else { -
2866 while(*--s == '0') {}
executed: }
Execution Count:3515
evaluated: *--s == '0'
TRUEFALSE
yes
Evaluation Count:3515
yes
Evaluation Count:1255
1255-3515
2867 s++;
executed (the execution status of this line is deduced): s++;
-
2868 }
executed: }
Execution Count:1255
1255
2869 ret:
code before this statement executed: ret:
Execution Count:2229
2229
2870 Bfree(S);
executed (the execution status of this line is deduced): Bfree(S);
-
2871 if (mhi) {
partially evaluated: mhi
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2232
0-2232
2872 if (mlo && mlo != mhi)
never evaluated: mlo
never evaluated: mlo != mhi
0
2873 Bfree(mlo);
never executed: Bfree(mlo);
0
2874 Bfree(mhi);
never executed (the execution status of this line is deduced): Bfree(mhi);
-
2875 }
never executed: }
0
2876 ret1:
code before this statement executed: ret1:
Execution Count:2232
2232
2877 Bfree(b);
executed (the execution status of this line is deduced): Bfree(b);
-
2878 if (s == s0) { /* don't return empty string */
evaluated: s == s0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1463099
2-1463099
2879 *s++ = '0';
executed (the execution status of this line is deduced): *s++ = '0';
-
2880 k = 0;
executed (the execution status of this line is deduced): k = 0;
-
2881 }
executed: }
Execution Count:2
2
2882 *s = 0;
executed (the execution status of this line is deduced): *s = 0;
-
2883 *decpt = k + 1;
executed (the execution status of this line is deduced): *decpt = k + 1;
-
2884 if (rve)
partially evaluated: rve
TRUEFALSE
yes
Evaluation Count:1463101
no
Evaluation Count:0
0-1463101
2885 *rve = s;
executed: *rve = s;
Execution Count:1463101
1463101
2886 return s0;
executed: return s0;
Execution Count:1463101
1463101
2887} -
2888#else -
2889// NOT thread safe! -
2890 -
2891#include <errno.h> -
2892 -
2893Q_CORE_EXPORT char *qdtoa( double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp) -
2894{ -
2895 if(rve) -
2896 *rve = 0; -
2897 -
2898 char *res; -
2899 if (mode == 0) -
2900 ndigits = 80; -
2901 -
2902 if (mode == 3) -
2903 res = fcvt(d, ndigits, decpt, sign); -
2904 else -
2905 res = ecvt(d, ndigits, decpt, sign); -
2906 -
2907 int n = qstrlen(res); -
2908 if (mode == 0) { // remove trailing 0's -
2909 const int stop = qMax(1, *decpt); -
2910 int i; -
2911 for (i = n-1; i >= stop; --i) { -
2912 if (res[i] != '0') -
2913 break; -
2914 } -
2915 n = i + 1; -
2916 } -
2917 *resultp = static_cast<char*>(malloc(n + 1)); -
2918 Q_CHECK_PTR(resultp); -
2919 qstrncpy(*resultp, res, n + 1); -
2920 return *resultp; -
2921} -
2922 -
2923Q_CORE_EXPORT double qstrtod(const char *s00, const char **se, bool *ok) -
2924{ -
2925 double ret = strtod((char*)s00, (char**)se); -
2926 if (ok) { -
2927 if((ret == 0.0l && errno == ERANGE) -
2928 || ret == HUGE_VAL || ret == -HUGE_VAL) -
2929 *ok = false; -
2930 else -
2931 *ok = true; // the result will be that we don't report underflow in this case -
2932 } -
2933 return ret; -
2934} -
2935 -
2936#endif // QT_QLOCALE_USES_FCVT -
2937 -
2938QT_END_NAMESPACE -
2939 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial