| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qlocale_tools.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | - | |||||||||||||||||||
| 6 | - | |||||||||||||||||||
| 7 | - | |||||||||||||||||||
| 8 | - | |||||||||||||||||||
| 9 | - | |||||||||||||||||||
| 10 | - | |||||||||||||||||||
| 11 | - | |||||||||||||||||||
| 12 | - | |||||||||||||||||||
| 13 | - | |||||||||||||||||||
| 14 | - | |||||||||||||||||||
| 15 | - | |||||||||||||||||||
| 16 | void doubleToAscii(double d, QLocaleData::DoubleForm form, int precision, char *buf, int bufSize, | - | ||||||||||||||||||
| 17 | bool &sign, int &length, int &decpt) | - | ||||||||||||||||||
| 18 | { | - | ||||||||||||||||||
| 19 | if (bufSize == 0
| 0-110646 | ||||||||||||||||||
| 20 | decpt = 0; | - | ||||||||||||||||||
| 21 | sign = d < 0; | - | ||||||||||||||||||
| 22 | length = 0; | - | ||||||||||||||||||
| 23 | return; never executed: return; | 0 | ||||||||||||||||||
| 24 | } | - | ||||||||||||||||||
| 25 | - | |||||||||||||||||||
| 26 | - | |||||||||||||||||||
| 27 | - | |||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | - | |||||||||||||||||||
| 30 | if (qt_is_inf(d)
| 550-110096 | ||||||||||||||||||
| 31 | sign = d < 0; | - | ||||||||||||||||||
| 32 | if (bufSize >= 3
| 0-550 | ||||||||||||||||||
| 33 | buf[0] = 'i'; | - | ||||||||||||||||||
| 34 | buf[1] = 'n'; | - | ||||||||||||||||||
| 35 | buf[2] = 'f'; | - | ||||||||||||||||||
| 36 | length = 3; | - | ||||||||||||||||||
| 37 | } executed 550 times by 4 tests: else {end of blockExecuted by:
| 550 | ||||||||||||||||||
| 38 | length = 0; | - | ||||||||||||||||||
| 39 | } never executed: end of block | 0 | ||||||||||||||||||
| 40 | return; executed 550 times by 4 tests: return;Executed by:
| 550 | ||||||||||||||||||
| 41 | } else if (qt_is_nan(d)
| 262-109834 | ||||||||||||||||||
| 42 | if (bufSize >= 3
| 0-262 | ||||||||||||||||||
| 43 | buf[0] = 'n'; | - | ||||||||||||||||||
| 44 | buf[1] = 'a'; | - | ||||||||||||||||||
| 45 | buf[2] = 'n'; | - | ||||||||||||||||||
| 46 | length = 3; | - | ||||||||||||||||||
| 47 | } executed 262 times by 3 tests: else {end of blockExecuted by:
| 262 | ||||||||||||||||||
| 48 | length = 0; | - | ||||||||||||||||||
| 49 | } never executed: end of block | 0 | ||||||||||||||||||
| 50 | return; executed 262 times by 3 tests: return;Executed by:
| 262 | ||||||||||||||||||
| 51 | } | - | ||||||||||||||||||
| 52 | - | |||||||||||||||||||
| 53 | if (form == QLocaleData::DFSignificantDigits
| 1729-107580 | ||||||||||||||||||
| 54 | precision = 1; executed 1729 times by 2 tests: precision = 1;Executed by:
| 1729 | ||||||||||||||||||
| 55 | - | |||||||||||||||||||
| 56 | - | |||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | if (form == QLocaleData::DFExponent
| 0-109817 | ||||||||||||||||||
| 59 | ++ executed 17 times by 3 tests: precision;++precision;Executed by:
executed 17 times by 3 tests: ++precision;Executed by:
| 17 | ||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | double_conversion::DoubleToStringConverter::DtoaMode mode; | - | ||||||||||||||||||
| 62 | if (precision == QLocale::FloatingPointShortest
| 144-109690 | ||||||||||||||||||
| 63 | mode = double_conversion::DoubleToStringConverter::SHORTEST; | - | ||||||||||||||||||
| 64 | } executed 144 times by 13 tests: else if (form == QLocaleData::DFSignificantDigitsend of blockExecuted by:
| 17-107436 | ||||||||||||||||||
| 65 | mode = double_conversion::DoubleToStringConverter::PRECISION; | - | ||||||||||||||||||
| 66 | } executed 107453 times by 36 tests: else {end of blockExecuted by:
| 107453 | ||||||||||||||||||
| 67 | mode = double_conversion::DoubleToStringConverter::FIXED; | - | ||||||||||||||||||
| 68 | } executed 2237 times by 20 tests: end of blockExecuted by:
| 2237 | ||||||||||||||||||
| 69 | double_conversion::DoubleToStringConverter::DoubleToAscii(d, mode, precision, buf, bufSize, | - | ||||||||||||||||||
| 70 | &sign, &length, &decpt); | - | ||||||||||||||||||
| 71 | while (length > 1
| 48689-159154 | ||||||||||||||||||
| 72 | -- executed 110465 times by 35 tests: length;--length;Executed by:
executed 110465 times by 35 tests: --length;Executed by:
| 110465 | ||||||||||||||||||
| 73 | } executed 109834 times by 55 tests: end of blockExecuted by:
| 109834 | ||||||||||||||||||
| 74 | - | |||||||||||||||||||
| 75 | double asciiToDouble(const char *num, int numLen, bool &ok, int &processed, | - | ||||||||||||||||||
| 76 | TrailingJunkMode trailingJunkMode) | - | ||||||||||||||||||
| 77 | { | - | ||||||||||||||||||
| 78 | if (*
| 0-4198 | ||||||||||||||||||
| 79 | ok = false; | - | ||||||||||||||||||
| 80 | processed = 0; | - | ||||||||||||||||||
| 81 | return never executed: 0.0;return 0.0;never executed: return 0.0; | 0 | ||||||||||||||||||
| 82 | } | - | ||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | ok = true; | - | ||||||||||||||||||
| 85 | - | |||||||||||||||||||
| 86 | - | |||||||||||||||||||
| 87 | - | |||||||||||||||||||
| 88 | - | |||||||||||||||||||
| 89 | if (qstrcmp(num, "nan") == 0
| 7-4191 | ||||||||||||||||||
| 90 | processed = 3; | - | ||||||||||||||||||
| 91 | return executed 7 times by 1 test: qt_snan();return qt_snan();Executed by:
executed 7 times by 1 test: return qt_snan();Executed by:
| 7 | ||||||||||||||||||
| 92 | } else if ((num[0] == '-'
| 2-3787 | ||||||||||||||||||
| 93 | processed = 0; | - | ||||||||||||||||||
| 94 | ok = false; | - | ||||||||||||||||||
| 95 | return executed 2 times by 1 test: 0.0;return 0.0;Executed by:
executed 2 times by 1 test: return 0.0;Executed by:
| 2 | ||||||||||||||||||
| 96 | } | - | ||||||||||||||||||
| 97 | - | |||||||||||||||||||
| 98 | - | |||||||||||||||||||
| 99 | - | |||||||||||||||||||
| 100 | if (qstrcmp(num, "+inf") == 0
| 3-4186 | ||||||||||||||||||
| 101 | processed = 4; | - | ||||||||||||||||||
| 102 | return executed 3 times by 1 test: qt_inf();return qt_inf();Executed by:
executed 3 times by 1 test: return qt_inf();Executed by:
| 3 | ||||||||||||||||||
| 103 | } else if (qstrcmp(num, "inf") == 0
| 6-4180 | ||||||||||||||||||
| 104 | processed = 3; | - | ||||||||||||||||||
| 105 | return executed 6 times by 1 test: qt_inf();return qt_inf();Executed by:
executed 6 times by 1 test: return qt_inf();Executed by:
| 6 | ||||||||||||||||||
| 106 | } else if (qstrcmp(num, "-inf") == 0
| 2-4178 | ||||||||||||||||||
| 107 | processed = 4; | - | ||||||||||||||||||
| 108 | return executed 2 times by 1 test: -qt_inf();return -qt_inf();Executed by:
executed 2 times by 1 test: return -qt_inf();Executed by:
| 2 | ||||||||||||||||||
| 109 | } | - | ||||||||||||||||||
| 110 | - | |||||||||||||||||||
| 111 | double d = 0.0; | - | ||||||||||||||||||
| 112 | - | |||||||||||||||||||
| 113 | int conv_flags = (
| 0-4178 | ||||||||||||||||||
| 114 | double_conversion::StringToDoubleConverter::ALLOW_TRAILING_JUNK : | - | ||||||||||||||||||
| 115 | double_conversion::StringToDoubleConverter::NO_FLAGS; | - | ||||||||||||||||||
| 116 | double_conversion::StringToDoubleConverter conv(conv_flags, 0.0, qt_snan(), 0, 0); | - | ||||||||||||||||||
| 117 | d = conv.StringToDouble(num, numLen, &processed); | - | ||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | if (!qIsFinite(d)
| 328-3850 | ||||||||||||||||||
| 120 | ok = false; | - | ||||||||||||||||||
| 121 | if (qIsNaN(d)
| 0-328 | ||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | processed = 0; | - | ||||||||||||||||||
| 124 | return executed 328 times by 11 tests: 0.0;return 0.0;Executed by:
executed 328 times by 11 tests: return 0.0;Executed by:
| 328 | ||||||||||||||||||
| 125 | } else { | - | ||||||||||||||||||
| 126 | - | |||||||||||||||||||
| 127 | return never executed: d;return d;never executed: return d; | 0 | ||||||||||||||||||
| 128 | } | - | ||||||||||||||||||
| 129 | } | - | ||||||||||||||||||
| 130 | ((!(trailingJunkMode == TrailingJunkAllowed || processed == numLen)) ? qt_assert("trailingJunkMode == TrailingJunkAllowed || processed == numLen",__FILE__,364) : qt_noop()); | - | ||||||||||||||||||
| 131 | - | |||||||||||||||||||
| 132 | - | |||||||||||||||||||
| 133 | if (isZero(d)
| 1182-2668 | ||||||||||||||||||
| 134 | for (int i = 0; i < processed
| 1182-4553 | ||||||||||||||||||
| 135 | if (num[i] >= '1'
| 0-4553 | ||||||||||||||||||
| 136 | - | |||||||||||||||||||
| 137 | ok = false; | - | ||||||||||||||||||
| 138 | return never executed: 0.0;return 0.0;never executed: return 0.0; | 0 | ||||||||||||||||||
| 139 | } else if (num[i] == 'e'
| 0-4553 | ||||||||||||||||||
| 140 | break; never executed: break; | 0 | ||||||||||||||||||
| 141 | } | - | ||||||||||||||||||
| 142 | } executed 4553 times by 18 tests: end of blockExecuted by:
| 4553 | ||||||||||||||||||
| 143 | } executed 1182 times by 18 tests: end of blockExecuted by:
| 1182 | ||||||||||||||||||
| 144 | return executed 3850 times by 26 tests: d;return d;Executed by:
executed 3850 times by 26 tests: return d;Executed by:
| 3850 | ||||||||||||||||||
| 145 | } | - | ||||||||||||||||||
| 146 | - | |||||||||||||||||||
| 147 | unsigned long long | - | ||||||||||||||||||
| 148 | qstrtoull(const char * nptr, const char **endptr, int base, bool *ok) | - | ||||||||||||||||||
| 149 | { | - | ||||||||||||||||||
| 150 | - | |||||||||||||||||||
| 151 | - | |||||||||||||||||||
| 152 | - | |||||||||||||||||||
| 153 | const char *begin = nptr; | - | ||||||||||||||||||
| 154 | while (ascii_isspace(*begin)) | - | ||||||||||||||||||
| 155 | ++begin; | - | ||||||||||||||||||
| 156 | if (*begin == '-') { | - | ||||||||||||||||||
| 157 | *ok = false; | - | ||||||||||||||||||
| 158 | return 0; | - | ||||||||||||||||||
| 159 | } | - | ||||||||||||||||||
| 160 | - | |||||||||||||||||||
| 161 | *ok = true; | - | ||||||||||||||||||
| 162 | (*__errno_location ()) = 0; | - | ||||||||||||||||||
| 163 | char *endptr2 = 0; | - | ||||||||||||||||||
| 164 | unsigned long long result = qt_strtoull(nptr, &endptr2, base); | - | ||||||||||||||||||
| 165 | if (endptr) | - | ||||||||||||||||||
| 166 | *endptr = endptr2; | - | ||||||||||||||||||
| 167 | if ((result == 0 || result == std::numeric_limits<unsigned long long>::max()) | - | ||||||||||||||||||
| 168 | && ((*__errno_location ()) || endptr2 == nptr)) { | - | ||||||||||||||||||
| 169 | *ok = false; | - | ||||||||||||||||||
| 170 | return 0; | - | ||||||||||||||||||
| 171 | } | - | ||||||||||||||||||
| 172 | return result; | - | ||||||||||||||||||
| 173 | } | - | ||||||||||||||||||
| 174 | - | |||||||||||||||||||
| 175 | long long | - | ||||||||||||||||||
| 176 | qstrtoll(const char * nptr, const char **endptr, int base, bool *ok) | - | ||||||||||||||||||
| 177 | { | - | ||||||||||||||||||
| 178 | *ok = true; | - | ||||||||||||||||||
| 179 | (*__errno_location ()) = 0; | - | ||||||||||||||||||
| 180 | char *endptr2 = 0; | - | ||||||||||||||||||
| 181 | long long result = qt_strtoll(nptr, &endptr2, base); | - | ||||||||||||||||||
| 182 | if (endptr) | - | ||||||||||||||||||
| 183 | *endptr = endptr2; | - | ||||||||||||||||||
| 184 | if ((result == 0 || result == std::numeric_limits<long long>::min() | - | ||||||||||||||||||
| 185 | || result == std::numeric_limits<long long>::max()) | - | ||||||||||||||||||
| 186 | && ((*__errno_location ()) || nptr == endptr2)) { | - | ||||||||||||||||||
| 187 | *ok = false; | - | ||||||||||||||||||
| 188 | return 0; | - | ||||||||||||||||||
| 189 | } | - | ||||||||||||||||||
| 190 | return result; | - | ||||||||||||||||||
| 191 | } | - | ||||||||||||||||||
| 192 | - | |||||||||||||||||||
| static char *_qdtoa( volatile double d, int mode, int ndigits, int *decpt, | ||||||||||||||||||||
| int *sign, char **rve, char **digits_str);QString qulltoa(qulonglong l, int base, const QChar _zero) | ||||||||||||||||||||
| 194 | { | - | ||||||||||||||||||
| 195 | ushort buff[65]; | - | ||||||||||||||||||
| 196 | ushort *p = buff + 65; | - | ||||||||||||||||||
| 197 | - | |||||||||||||||||||
| 198 | if (base != 10 || _zero.unicode() == '0') { | - | ||||||||||||||||||
| 199 | while (l != 0) { | - | ||||||||||||||||||
| 200 | int c = l % base; | - | ||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | --p; | - | ||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | if (c < 10) | - | ||||||||||||||||||
| 205 | *p = '0' + c; | - | ||||||||||||||||||
| 206 | else | - | ||||||||||||||||||
| 207 | *p = c - 10 + 'a'; | - | ||||||||||||||||||
| 208 | - | |||||||||||||||||||
| 209 | l /= base; | - | ||||||||||||||||||
| 210 | } | - | ||||||||||||||||||
| 211 | } | - | ||||||||||||||||||
| 212 | else { | - | ||||||||||||||||||
| 213 | while (l != 0) { | - | ||||||||||||||||||
| 214 | int c = l % base; | - | ||||||||||||||||||
| 215 | - | |||||||||||||||||||
| 216 | *(--p) = _zero.unicode() + c; | - | ||||||||||||||||||
| 217 | - | |||||||||||||||||||
| 218 | l /= base; | - | ||||||||||||||||||
| 219 | } | - | ||||||||||||||||||
| 220 | } | - | ||||||||||||||||||
| 221 | - | |||||||||||||||||||
| 222 | return QString(reinterpret_cast<QChar *>(p), 65 - (p - buff)); | - | ||||||||||||||||||
| 223 | } | - | ||||||||||||||||||
| 224 | - | |||||||||||||||||||
| 225 | QString qlltoa(qlonglong l, int base, const QChar zero) | - | ||||||||||||||||||
| 226 | { | - | ||||||||||||||||||
| 227 | return qulltoa(l < 0 ? -l : l, base, zero); | - | ||||||||||||||||||
| 228 | } | - | ||||||||||||||||||
| 229 | - | |||||||||||||||||||
| 230 | QString &decimalForm(QChar zero, QChar decimal, QChar group, | - | ||||||||||||||||||
| 231 | QString &digits, int decpt, uintint precision, | - | ||||||||||||||||||
| 232 | PrecisionMode pm, | - | ||||||||||||||||||
| 233 | bool always_show_decpt, | - | ||||||||||||||||||
| 234 | bool thousands_group) | - | ||||||||||||||||||
| 235 | { | - | ||||||||||||||||||
| 236 | if (decpt < 0
| 18518-84964 | ||||||||||||||||||
| 237 | for (int i = 0; i < -decpt
| 18518-46372 | ||||||||||||||||||
| 238 | digits.prepend(zero); executed 46372 times by 5 tests: digits.prepend(zero);Executed by:
| 46372 | ||||||||||||||||||
| 239 | decpt = 0; | - | ||||||||||||||||||
| 240 | } executed 18518 times by 5 tests: end of blockExecuted by:
| 18518 | ||||||||||||||||||
| 241 | else if (decpt > digits.length()
| 983-83981 | ||||||||||||||||||
| 242 | for (int i = digits.length(); i < decpt
| 983-2314 | ||||||||||||||||||
| 243 | digits.append(zero); executed 2314 times by 20 tests: digits.append(zero);Executed by:
| 2314 | ||||||||||||||||||
| 244 | } executed 983 times by 20 tests: end of blockExecuted by:
| 983 | ||||||||||||||||||
| 245 | - | |||||||||||||||||||
| 246 | if (pm == PMDecimalDigits
| 2237-101245 | ||||||||||||||||||
| 247 | uint decimal_digits = digits.length() - decpt; | - | ||||||||||||||||||
| 248 | for (uintint i = decimal_digits; i < precision
| 2237-9836 | ||||||||||||||||||
| 249 | digits.append(zero); executed 9836 times by 18 tests: digits.append(zero);Executed by:
| 9836 | ||||||||||||||||||
| 250 | } executed 2237 times by 20 tests: end of blockExecuted by:
| 2237 | ||||||||||||||||||
| 251 | else if (pm == PMSignificantDigits
| 2386-98859 | ||||||||||||||||||
| 252 | for (uintint i = digits.length(); i < precision
| 2386-7938 | ||||||||||||||||||
| 253 | digits.append(zero); executed 7938 times by 2 tests: digits.append(zero);Executed by:
| 7938 | ||||||||||||||||||
| 254 | } executed 2386 times by 2 tests: end of blockExecuted by:
| 2386 | ||||||||||||||||||
| 255 | else { | - | ||||||||||||||||||
| 256 | } executed 98859 times by 42 tests: end of blockExecuted by:
| 98859 | ||||||||||||||||||
| 257 | - | |||||||||||||||||||
| 258 | if (always_show_decpt
| 2388-101094 | ||||||||||||||||||
| 259 | digits.insert(decpt, decimal); executed 50083 times by 34 tests: digits.insert(decpt, decimal);Executed by:
| 50083 | ||||||||||||||||||
| 260 | - | |||||||||||||||||||
| 261 | if (thousands_group
| 5369-98113 | ||||||||||||||||||
| 262 | for (int i = decpt - 3; i > 0
| 2234-5369 | ||||||||||||||||||
| 263 | digits.insert(i, group); executed 2234 times by 3 tests: digits.insert(i, group);Executed by:
| 2234 | ||||||||||||||||||
| 264 | } executed 5369 times by 11 tests: end of blockExecuted by:
| 5369 | ||||||||||||||||||
| 265 | - | |||||||||||||||||||
| 266 | if (decpt == 0
| 45893-57589 | ||||||||||||||||||
| 267 | digits.prepend(zero); executed 45893 times by 13 tests: digits.prepend(zero);Executed by:
| 45893 | ||||||||||||||||||
| 268 | - | |||||||||||||||||||
| 269 | return executed 103482 times by 54 tests: digits;return digits;Executed by:
executed 103482 times by 54 tests: return digits;Executed by:
| 103482 | ||||||||||||||||||
| 270 | } | - | ||||||||||||||||||
| 271 | - | |||||||||||||||||||
| 272 | QString &exponentForm(QChar zero, QChar decimal, QChar exponential, | - | ||||||||||||||||||
| 273 | QChar group, QChar plus, QChar minus, | - | ||||||||||||||||||
| 274 | QString &digits, int decpt, uintint precision, | - | ||||||||||||||||||
| 275 | PrecisionMode pm, | - | ||||||||||||||||||
| 276 | bool always_show_decpt, | - | ||||||||||||||||||
| 277 | bool leading_zero_in_exponent) | - | ||||||||||||||||||
| 278 | { | - | ||||||||||||||||||
| 279 | int exp = decpt - 1; | - | ||||||||||||||||||
| 280 | - | |||||||||||||||||||
| 281 | if (pm == PMDecimalDigits
| 17-6335 | ||||||||||||||||||
| 282 | for (uintint i = digits.length(); i < precision + 1
| 16-17 | ||||||||||||||||||
| 283 | digits.append(zero); executed 16 times by 3 tests: digits.append(zero);Executed by:
| 16 | ||||||||||||||||||
| 284 | } executed 17 times by 3 tests: end of blockExecuted by:
| 17 | ||||||||||||||||||
| 285 | else if (pm == PMSignificantDigits
| 2224-4111 | ||||||||||||||||||
| 286 | for (uintint i = digits.length(); i < precision
| 1920-2224 | ||||||||||||||||||
| 287 | digits.append(zero); executed 1920 times by 1 test: digits.append(zero);Executed by:
| 1920 | ||||||||||||||||||
| 288 | } executed 2224 times by 1 test: end of blockExecuted by:
| 2224 | ||||||||||||||||||
| 289 | else { | - | ||||||||||||||||||
| 290 | } executed 4111 times by 5 tests: end of blockExecuted by:
| 4111 | ||||||||||||||||||
| 291 | - | |||||||||||||||||||
| 292 | if (always_show_decpt
| 1321-4126 | ||||||||||||||||||
| 293 | digits.insert(1, decimal); executed 5031 times by 5 tests: digits.insert(1, decimal);Executed by:
| 5031 | ||||||||||||||||||
| 294 | - | |||||||||||||||||||
| 295 | digits.append(exponential); | - | ||||||||||||||||||
| 296 | digits.append(QLocaleData::longLongToString(zero, group, plus, minus, | - | ||||||||||||||||||
| 297 | exp, leading_zero_in_exponent ? 2 : 1, 10, -1, QLocaleData::AlwaysShowSign)); | - | ||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | return executed 6352 times by 6 tests: digits;return digits;Executed by:
executed 6352 times by 6 tests: return digits;Executed by:
| 6352 | ||||||||||||||||||
| } | ||||||||||||||||||||
| static inline quint32 getWord0(const volatile double x) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| const volatile uchar *ptr = reinterpret_cast<const volatile uchar *>(&x); | ||||||||||||||||||||
| if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { | ||||||||||||||||||||
| return (ptr[0]<<24) + (ptr[1]<<16) + (ptr[2]<<8) + ptr[3]; | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| return (ptr[7]<<24) + (ptr[6]<<16) + (ptr[5]<<8) + ptr[4]; | ||||||||||||||||||||
| }} | ||||||||||||||||||||
| 301 | - | |||||||||||||||||||
| static inline void setWord0(volatiledouble *x, quint32 l) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| volatile uchar *ptr = reinterpret_cast<volatile uchar *>(x); | ||||||||||||||||||||
| if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { | ||||||||||||||||||||
| ptr[0] = uchar(l>>24); | ||||||||||||||||||||
| ptr[1] = uchar(l>>16); | ||||||||||||||||||||
| ptr[2] = uchar(l>>8); | ||||||||||||||||||||
| ptr[3] = uchar(l); | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| ptr[7] = uchar(l>>24); | ||||||||||||||||||||
| ptr[6] = uchar(l>>16); | ||||||||||||||||||||
| ptr[5] = uchar(l>>8); | ||||||||||||||||||||
| ptr[4] = uchar(l); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static inline quint32 getWord1qstrtod(const volatile double x) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| const volatile uchar *ptr = reinterpret_cast<const volatile uchar *>(&x); | ||||||||||||||||||||
| if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { | ||||||||||||||||||||
| return (ptr[4]<<24) + (ptr[5]<<16) + (ptr[6]<<8) + ptr[7]; | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| return (ptr[3]<<24) + (ptr[2]<<16) + (ptr[1]<<8) + ptr[0]; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static inline void setWord1(volatile double *x, quint32 l) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| volatile uchar *ptr = reinterpret_cast<uchar volatile *>(x); | ||||||||||||||||||||
| if (QSysInfo::ByteOrder == QSysInfo::BigEndian) { | ||||||||||||||||||||
| ptr[4] = uchar(l>>24); | ||||||||||||||||||||
| ptr[5] = uchar(l>>16); | ||||||||||||||||||||
| ptr[6] = uchar(l>>8); | ||||||||||||||||||||
| ptr[7] = uchar(l); | ||||||||||||||||||||
| } else { | ||||||||||||||||||||
| ptr[3] = uchar(l>>24); | ||||||||||||||||||||
| ptr[2] = uchar(l>>16); | ||||||||||||||||||||
| ptr[1] = uchar(l>>8); | ||||||||||||||||||||
| ptr[0] = uchar(l); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static inline void Storeinc(quint32char *&a, const quint32 &bs00, const quint32 &c) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| *a = (ushort(b) << 16) | ushort(c); | ||||||||||||||||||||
| ++a; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| struct | ||||||||||||||||||||
| Bigint { | ||||||||||||||||||||
| struct Bigint *next; | ||||||||||||||||||||
| int k, maxwds, signchar **se, wds; | ||||||||||||||||||||
| quint32 x[1]; | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| typedef struct Bigint Bigint; | ||||||||||||||||||||
| static Bigintbool *Balloc(int kok) | ||||||||||||||||||||
| 303 | { | - | ||||||||||||||||||
| 304 | const int x; | - | ||||||||||||||||||
| Bigint *rv; | ||||||||||||||||||||
| x = 1 << k; | ||||||||||||||||||||
| rvlen = static_cast<Bigint *>(malloc(sizeof(Bigint) + (x-1)*sizeof(qint32))); | ||||||||||||||||||||
| do { if (!(rv)) qBadAlloc(); } while (0); | ||||||||||||||||||||
| rv->k = k; | ||||||||||||||||||||
| rv->maxwds = x; | ||||||||||||||||||||
| rv->sign = rv->wds = 0; | ||||||||||||||||||||
| return rv; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static void Bfree(Bigint *v) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| free(v); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static Bigint *multadd(Bigint *b, int m, int a) | ||||||||||||||||||||
| {inti, wds; | ||||||||||||||||||||
| quint32 *x, y; | ||||||||||||||||||||
| quint32 xi, z; | ||||||||||||||||||||
| Bigint *b1; | ||||||||||||||||||||
| wds = b->wds; | ||||||||||||||||||||
| x = b->x; | ||||||||||||||||||||
| i = 0; | ||||||||||||||||||||
| do { | ||||||||||||||||||||
| xi = *x; | ||||||||||||||||||||
| y = (xi & 0xffff) * m + a; | ||||||||||||||||||||
| z = (xi >> 16) * m + (y >> 16); | ||||||||||||||||||||
| a = (z >> 16); | ||||||||||||||||||||
| *x++ = (z << 16) + (y & 0xffff); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| while(++i < wds); | ||||||||||||||||||||
| if (a) { | ||||||||||||||||||||
| if (wds >= b->maxwds) { | ||||||||||||||||||||
| b1 = Balloc(b->k+1); | ||||||||||||||||||||
| memcpy(reinterpret_cast<char *>(&b1->sign), reinterpret_cast<char *>(&b->sign), b->wds*sizeof(qint32) + 2*sizeof>(strlen(ints00)); | ||||||||||||||||||||
| 305 | Bfree(b); | - | ||||||||||||||||||
| b = b1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| b->x[wds++] = a; | ||||||||||||||||||||
| b->wds = wds; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return b; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static Bigint *s2b(const char *s, int nd0, int nd, quint32 y9) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| Bigint *b; | ||||||||||||||||||||
| int i, k; | ||||||||||||||||||||
| qint32 x, y; | ||||||||||||||||||||
| x = (nd + 8) / 9; | ||||||||||||||||||||
| for(k = 0, y = 1; x > y; y <<= 1, k++) ; | ||||||||||||||||||||
| b = Balloc(k); | ||||||||||||||||||||
| b->x[0] = y9; | ||||||||||||||||||||
| b->wds = 1; | ||||||||||||||||||||
| i = 9; | ||||||||||||||||||||
| if (9 < nd0) { | ||||||||||||||||||||
| s += 9; | ||||||||||||||||||||
| do b = multadd(b, 10, *s++ - '0'); | ||||||||||||||||||||
| while(++i < nd0); | ||||||||||||||||||||
| s++; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| s += 10; | ||||||||||||||||||||
| for(; i < nd; i++) | ||||||||||||||||||||
| b = multadd(b, 10, *s++ - '0'); | ||||||||||||||||||||
| return b; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static int hi0bits(quint32 x) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| int k = 0; | ||||||||||||||||||||
| if (!(x & 0xffff0000)) { | ||||||||||||||||||||
| k = 16; | ||||||||||||||||||||
| x <<= 16; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(x & 0xff000000)) { | ||||||||||||||||||||
| k += 8; | ||||||||||||||||||||
| x <<= 8; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(x & 0xf0000000)) { | ||||||||||||||||||||
| k += 4; | ||||||||||||||||||||
| x <<= 4; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(x & 0xc0000000)) { | ||||||||||||||||||||
| k += 2; | ||||||||||||||||||||
| x <<= 2; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(x & 0x80000000)) { | ||||||||||||||||||||
| k++; | ||||||||||||||||||||
| if (!(x & 0x40000000)) | ||||||||||||||||||||
| return 32; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return k; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static int lo0bits(quint32 *y) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| int k; | ||||||||||||||||||||
| quint32 x = *y; | ||||||||||||||||||||
| if (x & 7) { | ||||||||||||||||||||
| if (x & 1) | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
| if (x & 2) { | ||||||||||||||||||||
| *y = x >> 1; | ||||||||||||||||||||
| return 1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| *y = x >> 2; | ||||||||||||||||||||
| return 2; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| k = 0; | ||||||||||||||||||||
| if (!(x & 0xffff)) { | ||||||||||||||||||||
| k = 16; | ||||||||||||||||||||
| x >>= 16; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(x & 0xff)) { | ||||||||||||||||||||
| k += 8; | ||||||||||||||||||||
| x >>= 8; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(x & 0xf)) { | ||||||||||||||||||||
| k += 4; | ||||||||||||||||||||
| x >>= 4; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(x & 0x3)) { | ||||||||||||||||||||
| k += 2; | ||||||||||||||||||||
| x >>= 2; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(x & 1)) { | ||||||||||||||||||||
| k++; | ||||||||||||||||||||
| x >>= 1; | ||||||||||||||||||||
| if (!x & 1) | ||||||||||||||||||||
| return 32; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| *y = x; | ||||||||||||||||||||
| return k; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static Bigint *i2b(int i) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| Bigint *b; | ||||||||||||||||||||
| b = Balloc(1); | ||||||||||||||||||||
| b->x[0] = i; | ||||||||||||||||||||
| b->wds = 1; | ||||||||||||||||||||
| return b; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static Bigint *mult(Bigint *a, Bigint *b) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| Bigint *c; | ||||||||||||||||||||
| int k, wa, wb, wc; | ||||||||||||||||||||
| quint32 carry, y, z; | ||||||||||||||||||||
| quint32 *x, *xa, *xae, *xb, *xbe, *xc, *xc0; | ||||||||||||||||||||
| quint32 z2; | ||||||||||||||||||||
| if (a->wds < b->wds) { | ||||||||||||||||||||
| c = a; | ||||||||||||||||||||
| a = b; | ||||||||||||||||||||
| b = c; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| k = a->k; | ||||||||||||||||||||
| wa = a->wds; | ||||||||||||||||||||
| wb = b->wds; | ||||||||||||||||||||
| wc = wa + wb; | ||||||||||||||||||||
| if (wc > a->maxwds) | ||||||||||||||||||||
| k++; | ||||||||||||||||||||
| c = Balloc(k); | ||||||||||||||||||||
| for(x = c->x, xa = x + wc; x < xa; x++) | ||||||||||||||||||||
| *x = 0; | ||||||||||||||||||||
| xa = a->x; | ||||||||||||||||||||
| xae = xa + wa; | ||||||||||||||||||||
| xb = b->x; | ||||||||||||||||||||
| xbe = xb + wb; | ||||||||||||||||||||
| xc0 = c->x; | ||||||||||||||||||||
| for(; xb < xbe; xb++, xc0++) { | ||||||||||||||||||||
| if ((y = *xb & 0xffff) != 0) { | ||||||||||||||||||||
| x = xa; | ||||||||||||||||||||
| xc = xc0; | ||||||||||||||||||||
| carry = 0; | ||||||||||||||||||||
| do { | ||||||||||||||||||||
| z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; | ||||||||||||||||||||
| carry = z >> 16; | ||||||||||||||||||||
| z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; | ||||||||||||||||||||
| carry = z2 >> 16; | ||||||||||||||||||||
| Storeinc(xc, z2, z); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| while(x < xae); | ||||||||||||||||||||
| *xc = carry; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if ((y = *xb >> 16) != 0) { | ||||||||||||||||||||
| x = xa; | ||||||||||||||||||||
| xc = xc0; | ||||||||||||||||||||
| carry = 0; | ||||||||||||||||||||
| z2 = *xc; | ||||||||||||||||||||
| do { | ||||||||||||||||||||
| z = (*x & 0xffff) * y + (*xc >> 16) + carry; | ||||||||||||||||||||
| carry = z >> 16; | ||||||||||||||||||||
| Storeinc(xc, z, z2); | ||||||||||||||||||||
| z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; | ||||||||||||||||||||
| carry = z2 >> 16; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| while(x < xae); | ||||||||||||||||||||
| *xc = z2; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; | ||||||||||||||||||||
| c->wds = wc; | ||||||||||||||||||||
| return c; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static Bigint *p5s; | ||||||||||||||||||||
| struct p5s_deleter | ||||||||||||||||||||
| { | ||||||||||||||||||||
| ~p5s_deleter() | ||||||||||||||||||||
| { | ||||||||||||||||||||
| while (p5s) { | ||||||||||||||||||||
| Bigint *next = p5s->next; | ||||||||||||||||||||
| Bfree(p5s); | ||||||||||||||||||||
| p5s = next; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| static Bigint *pow5mult(Bigint *b, int k) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| Bigint *b1, *p5, *p51; | ||||||||||||||||||||
| int i; | ||||||||||||||||||||
| static const int p05[3] = { 5, 25, 125 }; | ||||||||||||||||||||
| if ((i = k & 3) != 0) | ||||||||||||||||||||
| b = multadd(b, p05[i-1], 0); | ||||||||||||||||||||
| if (!(k >>= 2)) | ||||||||||||||||||||
| return b; | ||||||||||||||||||||
| if (!(p5 = p5s)) { | ||||||||||||||||||||
| static p5s_deleter deleter; | ||||||||||||||||||||
| p5 = p5s = i2b(625); | ||||||||||||||||||||
| p5->next =((!(len >= 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| for(;;) { | ||||||||||||||||||||
| if (k & 1) { | ||||||||||||||||||||
| b1 = mult(b, p5); | ||||||||||||||||||||
| Bfree(b); | ||||||||||||||||||||
| b = b1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(k >>= 1)) | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| if (!(p51 = p5->next)) { | ||||||||||||||||||||
| p51 = p5->next = mult(p5,p5); | ||||||||||||||||||||
| p51->next = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| p5 = p51; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return b; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static Bigint *lshift(Bigint *b, int k) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| int i, k1, n, n1; | ||||||||||||||||||||
| Bigint *b1; | ||||||||||||||||||||
| quint32 *x, *x1, *xe, z; | ||||||||||||||||||||
| n = k >> 5; | ||||||||||||||||||||
| k1 = b->k; | ||||||||||||||||||||
| n1 = n + b->wds + 1; | ||||||||||||||||||||
| for(i = b->maxwds; n1 > i; i <<= 1) | ||||||||||||||||||||
| k1++; | ||||||||||||||||||||
| b1 = Balloc(k1); | ||||||||||||||||||||
| x1 = b1->x; | ||||||||||||||||||||
| for(i = 0; i < n; i++) | ||||||||||||||||||||
| *x1++ = 0; | ||||||||||||||||||||
| x = b->x; | ||||||||||||||||||||
| xe = x + b->wds; | ||||||||||||||||||||
| if (k &= 0x1f) { | ||||||||||||||||||||
| k1 = 32 - k; | ||||||||||||||||||||
| z = 0; | ||||||||||||||||||||
| do { | ||||||||||||||||||||
| *x1++ = *x << k | z; | ||||||||||||||||||||
| z = *x++ >> k1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| while(x < xe); | ||||||||||||||||||||
| if ((*x1 = z) != 0) | ||||||||||||||||||||
| ++n1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else do | ||||||||||||||||||||
| *x1++ = *x++; | ||||||||||||||||||||
| while(x < xe); | ||||||||||||||||||||
| b1->wds = n1 - 1; | ||||||||||||||||||||
| Bfree(b); | ||||||||||||||||||||
| return b1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static int cmp(Bigint *a, Bigint *b) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| quint32 *xa, *xa0, *xb, *xb0; | ||||||||||||||||||||
| int i, j; | ||||||||||||||||||||
| i = a->wds; | ||||||||||||||||||||
| j = b->wds; | ||||||||||||||||||||
| if (i -= j) | ||||||||||||||||||||
| return i; | ||||||||||||||||||||
| xa0 = a->x; | ||||||||||||||||||||
| xa = xa0 + j; | ||||||||||||||||||||
| xb0 = b->x; | ||||||||||||||||||||
| xb = xb0 + j; | ||||||||||||||||||||
| for(;;) { | ||||||||||||||||||||
| if (*--xa != *--xb) | ||||||||||||||||||||
| return *xa < *xb? -1 : 1; | ||||||||||||||||||||
| if (xa <= xa0) | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static Bigint *diff(Bigint *a, Bigint *b) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| Bigint *c; | ||||||||||||||||||||
| int i, wa, wb; | ||||||||||||||||||||
| qint32 borrow, y; | ||||||||||||||||||||
| quint32 *xa, *xae, *xb, *xbe, *xc; | ||||||||||||||||||||
| qint32 z; | ||||||||||||||||||||
| i = cmp(a,b); | ||||||||||||||||||||
| if (!i) { | ||||||||||||||||||||
| c = Balloc(0); | ||||||||||||||||||||
| c->wds = 1; | ||||||||||||||||||||
| c->x[0] = 0; | ||||||||||||||||||||
| return c; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (i < 0) { | ||||||||||||||||||||
| c = a; | ||||||||||||||||||||
| a = b; | ||||||||||||||||||||
| b = c; | ||||||||||||||||||||
| i = 1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| i = 0; | ||||||||||||||||||||
| c = Balloc(a->k); | ||||||||||||||||||||
| c->sign = i; | ||||||||||||||||||||
| wa = a->wds; | ||||||||||||||||||||
| xa = a->x; | ||||||||||||||||||||
| xae = xa + wa; | ||||||||||||||||||||
| wb = b->wds; | ||||||||||||||||||||
| xb = b->x; | ||||||||||||||||||||
| xbe = xb + wb; | ||||||||||||||||||||
| xc = c->x; | ||||||||||||||||||||
| borrow = 0; | ||||||||||||||||||||
| do { | ||||||||||||||||||||
| y = (*xa & 0xffff) - (*xb & 0xffff) + borrow; | ||||||||||||||||||||
| borrow = y >> 16; | ||||||||||||||||||||
| ; | ||||||||||||||||||||
| z = (*xa++ >> 16) - (*xb++ >> 16) + borrow; | ||||||||||||||||||||
| borrow = z >> 16; | ||||||||||||||||||||
| ; | ||||||||||||||||||||
| Storeinc(xc, z, y); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| while(xb < xbe); | ||||||||||||||||||||
| while(xa < xae) { | ||||||||||||||||||||
| y = (*xa & 0xffff) + borrow; | ||||||||||||||||||||
| borrow = y >> 16; | ||||||||||||||||||||
| ; | ||||||||||||||||||||
| z = (*xa++ >> 16) + borrow; | ||||||||||||||||||||
| borrow = z >> 16; | ||||||||||||||||||||
| ; | ||||||||||||||||||||
| Storeinc(xc, z, y); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| while(!*--xc) | ||||||||||||||||||||
| wa--; | ||||||||||||||||||||
| c->wds = wa; | ||||||||||||||||||||
| return c; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static double ulp(double x) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| qint32 L; | ||||||||||||||||||||
| double a; | ||||||||||||||||||||
| L = (getWord0(x) & 0x7ff00000) - (53 -1)*0x100000; | ||||||||||||||||||||
| if (L > 0) { | ||||||||||||||||||||
| setWord0(&a, L); | ||||||||||||||||||||
| setWord1(&a, 0); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| L = -L >> 20; | ||||||||||||||||||||
| if (L < 20) { | ||||||||||||||||||||
| setWord0(&a, 0x80000 >> L); | ||||||||||||||||||||
| setWord1(&a, 0); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| setWord0(&a, 0); | ||||||||||||||||||||
| L -= 20; | ||||||||||||||||||||
| setWord1qt_assert(&a, L"len >=31 ? 1U : 1U << (31 - L)); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return a; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static double b2d(Bigint *a, int *e) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| quint32 *xa, *xa0, w, y, z; | ||||||||||||||||||||
| int k; | ||||||||||||||||||||
| double d; | ||||||||||||||||||||
| xa0 = a->x; | ||||||||||||||||||||
| xa = xa0 + a->wds; | ||||||||||||||||||||
| y = *--xa; | ||||||||||||||||||||
| k = hi0bits(y); | ||||||||||||||||||||
| *e = 32 - k; | ||||||||||||||||||||
| if (k < 11) { | ||||||||||||||||||||
| setWord0(&d, 0x3ff00000 | y >> (11 - k)); | ||||||||||||||||||||
| w = xa > xa0 ? *--xa : 0; | ||||||||||||||||||||
| setWord1(&d, y << ((32-11) + k) | w >> (11 - k)); | ||||||||||||||||||||
| goto ret_d; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| z = xa > xa0 ? *--xa : 0; | ||||||||||||||||||||
| if (k -= 11) { | ||||||||||||||||||||
| setWord0(&d, 0x3ff00000 | y << k | z >> (32 - k)); | ||||||||||||||||||||
| y = xa > xa0 ? *--xa : 0; | ||||||||||||||||||||
| setWord1(&d, z << k | y >> (32 - k)); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| setWord0(&d, 0x3ff00000 | y); | ||||||||||||||||||||
| setWord1(&d, z); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| ret_d: | ||||||||||||||||||||
| return d; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| static Bigint *d2b(double d, int *e, int *bits) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| Bigint *b; | ||||||||||||||||||||
| int de, i, k; | ||||||||||||||||||||
| quint32 *x, y 0",z; | ||||||||||||||||||||
| b = Balloc(1); | ||||||||||||||||||||
| x = b->x; | ||||||||||||||||||||
| z = getWord0(d) & 0xfffff; | ||||||||||||||||||||
| setWord0(&d__FILE__,getWord0(d) & 0x7fffffff); | ||||||||||||||||||||
| if ((de = int(getWord0(d) >> 20)) != 0) | ||||||||||||||||||||
| z |= 0x100000; | ||||||||||||||||||||
| if ((y = getWord1(d)) != 0) { | ||||||||||||||||||||
| if ((k = lo0bits(&y)) != 0) { | ||||||||||||||||||||
| x[0] = y | z << (32 - k); | ||||||||||||||||||||
| z >>= k; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| x[0] = y; | ||||||||||||||||||||
| i = b->wds = (x[1] = z539) ? 2: 1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| k = lo0bits(&z); | ||||||||||||||||||||
| x[0] = z; | ||||||||||||||||||||
| i = b->wds = 1; | ||||||||||||||||||||
| k += 32; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (de) { | ||||||||||||||||||||
| *e = de - 1023 - (53 -1) + k; | ||||||||||||||||||||
| *bits = 53 - k; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| *e = de - 1023 - (53 -1) + 1 + k; | ||||||||||||||||||||
| *bits = 32*i - hi0bits(x[i-1]); | ||||||||||||||||||||
| }qt_noop()); | ||||||||||||||||||||
| 306 | return never executed: b;return qstrntod(s00, len, se, ok);never executed: return qstrntod(s00, len, se, ok); | 0 | ||||||||||||||||||
| } never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| static double ratio(Bigint *a, Bigint *b) never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| { never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| double da, db; never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| int k, ka, kb; never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| da = b2d(a, &ka); never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| db = b2d never executed: return qstrntod(s00, len, se, ok);never executed: qstrntod(bs00, &kb);return qstrntod(s00, len, se, ok);never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| k = ka - kb + 32*(a->wds - b->wds); never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| if (k > 0) never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| setWord0(&da never executed: return qstrntod(s00, len, se, ok);never executed: len, getWord0(da) + k*0x100000);return qstrntod(s00, len, se, ok);never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| else { never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| k = -k; never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| setWord0(&db never executed: return qstrntod(s00, len, se, ok);never executed: se, getWord0(db) + k*0x100000ok);return qstrntod(s00, len, se, ok);never executed: return qstrntod(s00, len, se, ok); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| return da / db;} | ||||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 | - | |||||||||||||||||||
| static const double tens[] = { | ||||||||||||||||||||
| 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, | ||||||||||||||||||||
| 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, | ||||||||||||||||||||
| 1e20, 1e21, 1e22 | ||||||||||||||||||||
| }; | ||||||||||||||||||||
| static const double bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; | ||||||||||||||||||||
| static const double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 }; | ||||||||||||||||||||
| static double g_double_zero = 0.0; | ||||||||||||||||||||
| __attribute__((visibility("default")))double qstrtodqstrntod(const char *s00, int len, const char **se, bool *ok) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, | ||||||||||||||||||||
| e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; | ||||||||||||||||||||
| const char *s, *s0, *s1; | ||||||||||||||||||||
| double aadj, aadj1, adj, rv, rv0; | ||||||||||||||||||||
| qint32 L; | ||||||||||||||||||||
| quint32 y, z; | ||||||||||||||||||||
| Bigint *bb1, *bd0; | ||||||||||||||||||||
| Bigint *bb = __null, *bd = __null, *bs = __null, *delta = __null; | ||||||||||||||||||||
| if (ok != 0)*ok= true; | ||||||||||||||||||||
| const char decimal_point = '.'; | ||||||||||||||||||||
| sign = nz0 = nz = 0; | ||||||||||||||||||||
| rv = 0.; | ||||||||||||||||||||
| for(s = s00; ascii_isspace(uchar(*s)); s++) | ||||||||||||||||||||
| ; | ||||||||||||||||||||
| if (*s == '-') { | ||||||||||||||||||||
| sign = 1; | ||||||||||||||||||||
| s++; | ||||||||||||||||||||
| } else if (*s == '+') { | ||||||||||||||||||||
| s++; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (*s == '\0') { | ||||||||||||||||||||
| s = s00; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (*s == '0') { | ||||||||||||||||||||
| nz0 = 1; | ||||||||||||||||||||
| while(*++s == '0') ; | ||||||||||||||||||||
| if (!*s) | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| s0 = s; | ||||||||||||||||||||
| y = z = 0; | ||||||||||||||||||||
| for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) | ||||||||||||||||||||
| if (nd < 9) | ||||||||||||||||||||
| y = 10*y + c - '0'; | ||||||||||||||||||||
| else if (nd < 16) | ||||||||||||||||||||
| z = 10*z + c - '0'; | ||||||||||||||||||||
| nd0 = nd; | ||||||||||||||||||||
| if (c == decimal_point) { | ||||||||||||||||||||
| c = *++s; | ||||||||||||||||||||
| if (!nd) { | ||||||||||||||||||||
| for(; c == '0'; c = *++s) | ||||||||||||||||||||
| nz++; | ||||||||||||||||||||
| if (c > '0' && c <= '9') { | ||||||||||||||||||||
| s0 = s; | ||||||||||||||||||||
| nf += nz; | ||||||||||||||||||||
| nz = 0; | ||||||||||||||||||||
| goto have_dig; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| goto dig_done; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| for(; c >= '0' && c <= '9'; c = *++s) { | ||||||||||||||||||||
| have_dig: | ||||||||||||||||||||
| nz++; | ||||||||||||||||||||
| if (c -= '0') { | ||||||||||||||||||||
| nf += nz; | ||||||||||||||||||||
| for(i = 1; i < nz; i++) | ||||||||||||||||||||
| if (nd++ < 9) | ||||||||||||||||||||
| y *= 10; | ||||||||||||||||||||
| else if (nd <= 15 + 1) | ||||||||||||||||||||
| z *= 10; | ||||||||||||||||||||
| if (nd++ < 9) | ||||||||||||||||||||
| y = 10*y + c; | ||||||||||||||||||||
| else if (nd <= 15 + 1) | ||||||||||||||||||||
| z = 10*z + c; | ||||||||||||||||||||
| nz = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| dig_done: | ||||||||||||||||||||
| e = 0; | ||||||||||||||||||||
| if (c == 'e' || c == 'E') { | ||||||||||||||||||||
| if (!nd && !nz && !nz0) { | ||||||||||||||||||||
| s = s00; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| s00 = s; | ||||||||||||||||||||
| esign = 0; | ||||||||||||||||||||
| switch(c = *++s) { | ||||||||||||||||||||
| case '-': | ||||||||||||||||||||
| esign = 1; | ||||||||||||||||||||
| case '+': | ||||||||||||||||||||
| c = *++s; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (c >= '0' && c <= '9') { | ||||||||||||||||||||
| while(c == '0') | ||||||||||||||||||||
| c = *++s; | ||||||||||||||||||||
| if (c > '0' && c <= '9') | ||||||||||||||||||||
| 315 | { | - | ||||||||||||||||||
| 316 | L = c - '0'; | - | ||||||||||||||||||
| s1 = s; | ||||||||||||||||||||
| while((c = *++s) >= '0' && c <= '9') | ||||||||||||||||||||
| L = 10*L + c - '0'; | ||||||||||||||||||||
| if (s - s1 > 8 || L > 19999) | ||||||||||||||||||||
| e = 19999; | ||||||||||||||||||||
| else | ||||||||||||||||||||
| e =int (L); | ||||||||||||||||||||
| if (esign) | ||||||||||||||||||||
| e = -e; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| e = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| s = s00; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!nd) { | ||||||||||||||||||||
| if (!nz && !nz0) | ||||||||||||||||||||
| s = s00; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| e1 = e -= nf; | ||||||||||||||||||||
| if (!nd0) | ||||||||||||||||||||
| nd0 = nd; | ||||||||||||||||||||
| k = nd < 15 + 1 ? nd : 15 + 1; | ||||||||||||||||||||
| rv = y; | ||||||||||||||||||||
| if (k > 9) | ||||||||||||||||||||
| rv = tens[k - 9] * rv + z; | ||||||||||||||||||||
| bd0 = 0; | ||||||||||||||||||||
| if (nd <= 15 | ||||||||||||||||||||
| && 1 == 1 | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| if (!e) | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| if (e > 0) { | ||||||||||||||||||||
| if (e <= 22) { | ||||||||||||||||||||
| rv *= tens[e]; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| i = 15 - nd; | ||||||||||||||||||||
| if (e <= 22 + i) { | ||||||||||||||||||||
| e -= i; | ||||||||||||||||||||
| rv *= tens[i]; | ||||||||||||||||||||
| rv *= tens[e]; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (e >= -22) { | ||||||||||||||||||||
| rv /= tens[-e]; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| e1 += nd - k; | ||||||||||||||||||||
| if (e1 > 0) { | ||||||||||||||||||||
| if ((i = e1 & 15) != 0) | ||||||||||||||||||||
| rv *= tens[i]; | ||||||||||||||||||||
| if (e1 &= ~15) { | ||||||||||||||||||||
| if (e1 > 308) { | ||||||||||||||||||||
| ovfl: | ||||||||||||||||||||
| if (ok != 0) | ||||||||||||||||||||
| *ok = false; | ||||||||||||||||||||
| rv = (__builtin_huge_val()); | ||||||||||||||||||||
| if (bd0) | ||||||||||||||||||||
| goto retfree; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (e1 >>= 4) { | ||||||||||||||||||||
| for(j = 0; e1 > 1; j++, e1 >>= 1) | ||||||||||||||||||||
| if (e1 & 1) | ||||||||||||||||||||
| rv *= bigtens[j]; | ||||||||||||||||||||
| setWord0(&rv, getWord0(rv) - 53*0x100000); | ||||||||||||||||||||
| rv *= bigtens[j]; | ||||||||||||||||||||
| if ((z = getWord0(rv) & 0x7ff00000) | ||||||||||||||||||||
| > 0x100000*(1024 +1023 -53)) | ||||||||||||||||||||
| goto ovfl; | ||||||||||||||||||||
| if (z > 0x100000*(1024 +1023 -1-53)) { | ||||||||||||||||||||
| setWord0(&rv, (0xfffff | 0x100000*(1024 +1023 -1))); | ||||||||||||||||||||
| setWord1(&rv, 0xffffffff); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| setWord0(&rv, getWord0(rv) + 53*0x100000); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (e1 < 0) { | ||||||||||||||||||||
| e1 = -e1; | ||||||||||||||||||||
| if ((i = e1 & 15) != 0) | ||||||||||||||||||||
| rv /= tens[i]; | ||||||||||||||||||||
| if (e1 &= ~15) { | ||||||||||||||||||||
| e1 >>= 4; | ||||||||||||||||||||
| if (e1 >= 1 << 5) | ||||||||||||||||||||
| goto undfl; | ||||||||||||||||||||
| for(jprocessed = 0; e1 > 1; j++, e1 >>= 1) | ||||||||||||||||||||
| if (e1 & 1) | ||||||||||||||||||||
| rv *= tinytens[j]; | ||||||||||||||||||||
| rv0 = rv; | ||||||||||||||||||||
| rv *= tinytens[j]; | ||||||||||||||||||||
| if (rv == g_double_zero) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| rv = 2.*rv0; | ||||||||||||||||||||
| 317 | rv *= tinytens[j]; | - | ||||||||||||||||||
| if (rv == g_double_zero) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| undfl: | ||||||||||||||||||||
| rv = 0.; | ||||||||||||||||||||
| if (ok != 0) | ||||||||||||||||||||
| *okbool nonNullOk = false; | ||||||||||||||||||||
| if (bd0) | ||||||||||||||||||||
| goto retfree; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| setWord0(&rv, 0); | ||||||||||||||||||||
| setWord1(&rv, 1); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| bd0 = s2b(s0, nd0, nd, y); | ||||||||||||||||||||
| for(;;) { | ||||||||||||||||||||
| bd = Balloc(bd0->k); | ||||||||||||||||||||
| memcpy(reinterpret_cast<char *>(&bd->sign), reinterpret_cast<char *>(&bd0->sign), bd0->wds*sizeof(qint32) + 2*sizeof(int)); | ||||||||||||||||||||
| bb = d2b(rv, &bbe, &bbbits); | ||||||||||||||||||||
| bs = i2b(1); | ||||||||||||||||||||
| if (e >= 0) { | ||||||||||||||||||||
| bb2 = bb5 = 0; | ||||||||||||||||||||
| bd2 = bd5 = e; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| bb2 = bb5 = -e; | ||||||||||||||||||||
| bd2 = bd5 = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (bbe >= 0) | ||||||||||||||||||||
| bb2 += bbe; | ||||||||||||||||||||
| else | ||||||||||||||||||||
| bd2 -= bbe; | ||||||||||||||||||||
| bs2 = bb2; | ||||||||||||||||||||
| i = bbe + bbbits - 1; | ||||||||||||||||||||
| if (i < (-1022)) | ||||||||||||||||||||
| j = bbe + (53 -(-1022)); | ||||||||||||||||||||
| else | ||||||||||||||||||||
| j = 53 + 1 - bbbits; | ||||||||||||||||||||
| bb2 += j; | ||||||||||||||||||||
| bd2 += j; | ||||||||||||||||||||
| i = bb2 < bd2 ? bb2 : bd2; | ||||||||||||||||||||
| if (i > bs2) | ||||||||||||||||||||
| i = bs2; | ||||||||||||||||||||
| if (i > 0) { | ||||||||||||||||||||
| bb2 -= i; | ||||||||||||||||||||
| bd2 -= i; | ||||||||||||||||||||
| bs2 -= i; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (bb5 > 0) { | ||||||||||||||||||||
| bs = pow5mult(bs, bb5); | ||||||||||||||||||||
| bb1 = mult(bs, bb); | ||||||||||||||||||||
| Bfree(bb); | ||||||||||||||||||||
| bb = bb1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (bb2 > 0) | ||||||||||||||||||||
| bb = lshift(bb, bb2); | ||||||||||||||||||||
| if (bd5 > 0) | ||||||||||||||||||||
| bd = pow5mult(bd, bd5); | ||||||||||||||||||||
| if (bd2 > 0) | ||||||||||||||||||||
| bd = lshift(bd, bd2); | ||||||||||||||||||||
| if (bs2 > 0) | ||||||||||||||||||||
| bs = lshift(bs, bs2); | ||||||||||||||||||||
| delta = diff(bb, bd); | ||||||||||||||||||||
| dsign = delta->sign; | ||||||||||||||||||||
| delta->sign = 0; | ||||||||||||||||||||
| i = cmp(delta, bs); | ||||||||||||||||||||
| if (i < 0) { | ||||||||||||||||||||
| if (dsign || getWord1(rv) || getWord0(rv) & 0xfffff) | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| delta = lshift(delta,1); | ||||||||||||||||||||
| if (cmp(delta, bs) > 0) | ||||||||||||||||||||
| goto drop_down; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (i == 0) { | ||||||||||||||||||||
| if (dsign) { | ||||||||||||||||||||
| if ((getWord0(rv) & 0xfffff) == 0xfffff | ||||||||||||||||||||
| && getWord1(rv) == 0xffffffff) { | ||||||||||||||||||||
| setWord0(&rv, (getWord0(rv) & 0x7ff00000) | ||||||||||||||||||||
| + 0x100000 | ||||||||||||||||||||
| ); | ||||||||||||||||||||
| setWord1(&rv, 0); | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (!(getWord0(rv) & 0xfffff) && !getWord1(rv)) { | ||||||||||||||||||||
| drop_down: | ||||||||||||||||||||
| L = (getWord0(rv) & 0x7ff00000) - 0x100000; | ||||||||||||||||||||
| setWord0(&rv, L | 0xfffff); | ||||||||||||||||||||
| setWord1(&rv, 0xffffffff); | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (!(getWord1(rv) & 1)) | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| if (dsign) | ||||||||||||||||||||
| rv += ulp(rv); | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| rv -= ulp(rv); | ||||||||||||||||||||
| if (rv == g_double_zero) | ||||||||||||||||||||
| goto undfl; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if ((aadj = ratio(delta, bs)) <= 2.) { | ||||||||||||||||||||
| if (dsign) | ||||||||||||||||||||
| aadj = aadj1 = 1.; | ||||||||||||||||||||
| else if (getWord1(rv) || getWord0(rv) & 0xfffff) { | ||||||||||||||||||||
| if (getWord1(rv) == 1 && !getWord0(rv)) | ||||||||||||||||||||
| goto undfl; | ||||||||||||||||||||
| aadj = 1.; | ||||||||||||||||||||
| aadj1 = -1.; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| if (aadj < 2./2) | ||||||||||||||||||||
| aadj = 1./2; | ||||||||||||||||||||
| else | ||||||||||||||||||||
| aadj *= 0.5; | ||||||||||||||||||||
| aadj1 = -aadj; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| aadj *= 0.5; | ||||||||||||||||||||
| aadj1 = dsign ? aadj : -aadj; | ||||||||||||||||||||
| if (1 == 0) | ||||||||||||||||||||
| aadj1 += 0.5; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| y = getWord0(rv) & 0x7ff00000; | ||||||||||||||||||||
| 318 | if (y == 0x100000*(1024 +1023 -1)) { | - | ||||||||||||||||||
| rv0double d = rv; | ||||||||||||||||||||
| setWord0asciiToDouble(&rvs00, getWord0(rv) - 53*0x100000); | ||||||||||||||||||||
| adj = aadj1 * ulp(rv); | ||||||||||||||||||||
| rv += adj; | ||||||||||||||||||||
| if ((getWord0(rv) & 0x7ff00000) >= | ||||||||||||||||||||
| 0x100000*(1024 +1023 -53)) { | ||||||||||||||||||||
| if (getWord0(rv0) == (0xfffff | 0x100000*(1024 +1023 -1)) && getWord1(rv0) == 0xffffffff) | ||||||||||||||||||||
| goto ovfl; | ||||||||||||||||||||
| setWord0(&rvlen, (0xfffff | 0x100000*(1024 +1023 -1))); | ||||||||||||||||||||
| setWord1(&rvnonNullOk, 0xffffffff); | ||||||||||||||||||||
| goto cont; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| setWord0(&rvprocessed, getWord0(rv) + 53*0x100000); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| if (y <= (53 -1)*0x100000 && aadj >= 1.) { | ||||||||||||||||||||
| aadj1 = int(aadj + 0.5); | ||||||||||||||||||||
| if (!dsign) | ||||||||||||||||||||
| aadj1 = -aadj1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| adj = aadj1 * ulp(rv); | ||||||||||||||||||||
| rv += adj; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| z = getWord0(rv) & 0x7ff00000; | ||||||||||||||||||||
| if (y == z) { | ||||||||||||||||||||
| L = qint32(aadj); | ||||||||||||||||||||
| aadj -= L; | ||||||||||||||||||||
| if (dsign || getWord1(rv) || getWord0(rv) & 0xfffff) { | ||||||||||||||||||||
| if (aadj < .4999999 || aadj > .5000001) | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (aadj < .4999999/2) | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| cont: | ||||||||||||||||||||
| Bfree(bb); | ||||||||||||||||||||
| Bfree(bd); | ||||||||||||||||||||
| Bfree(bs); | ||||||||||||||||||||
| Bfree(delta); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| retfree: | ||||||||||||||||||||
| Bfree(bb); | ||||||||||||||||||||
| Bfree(bd); | ||||||||||||||||||||
| Bfree(bs); | ||||||||||||||||||||
| Bfree(bd0); | ||||||||||||||||||||
| Bfree(deltaTrailingJunkAllowed); | ||||||||||||||||||||
| 319 | ret:if (se
| 0 | ||||||||||||||||||
| 320 | * never executed: se = s;*se = s00 + processed;never executed: *se = s00 + processed; | 0 | ||||||||||||||||||
| return sign ? -rv : rv; never executed: *se = s00 + processed; | ||||||||||||||||||||
| } never executed: *se = s00 + processed; | ||||||||||||||||||||
| static int quorem(Bigint *b, Bigint *S) never executed: *se = s00 + processed; | ||||||||||||||||||||
| { never executed: *se = s00 + processed; | ||||||||||||||||||||
| int n; never executed: *se = s00 + processed; | ||||||||||||||||||||
| qint32 borrow, y; never executed: *se = s00 + processed; | ||||||||||||||||||||
| quint32 carry, q, ys; never executed: *se = s00 + processed; | ||||||||||||||||||||
| quint32 *bx, *bxe, *sx, *sxe; never executed: *se = s00 + processed; | ||||||||||||||||||||
| qint32 z; never executed: *se = s00 + processed; | ||||||||||||||||||||
| quint32 si, zs; never executed: *se = s00 + processed; | ||||||||||||||||||||
| n = S->wds; never executed: *se = s00 + processed; | ||||||||||||||||||||
| if (b->wds < n) never executed: *se = s00 + processed; | ||||||||||||||||||||
| return 0; never executed: *se = s00 + processed; | ||||||||||||||||||||
| sx = S->x; never executed: *se = s00 + processed; | ||||||||||||||||||||
| sxe = sx + --n; never executed: *se = s00 + processed; | ||||||||||||||||||||
| bx = b->x; never executed: *se = s00 + processed; | ||||||||||||||||||||
| bxe = bx + n; never executed: *se = s00 + processed; | ||||||||||||||||||||
| q = *bxe / (*sxe + 1); never executed: *se = s00 + processed; | ||||||||||||||||||||
| if (q) { never executed: *se = s00 + processed; | ||||||||||||||||||||
| borrow = 0; never executed: *se = s00 + processed; | ||||||||||||||||||||
| carry = 0; never executed: *se = s00 + processed; | ||||||||||||||||||||
| do { never executed: *se = s00 + processed; | ||||||||||||||||||||
| si = *sx++; never executed: *se = s00 + processed; | ||||||||||||||||||||
| ys = (si & 0xffff) * q + carry; never executed: *se = s00 + processed; | ||||||||||||||||||||
| zs = (si >> 16) * q + (ys >> 16); never executed: *se = s00 + processed; | ||||||||||||||||||||
| carry = zs >> 16; never executed: *se = s00 + processed; | ||||||||||||||||||||
| y = (*bx & 0xffff) - (ys & 0xffff) + borrow; never executed: *se = s00 + processed; | ||||||||||||||||||||
| borrow = y >> 16; never executed: *se = s00 + processed; | ||||||||||||||||||||
| ; never executed: *se = s00 + processed; | ||||||||||||||||||||
| z never executed: *se = s00 + processed;never executed: = (*bx >> 16) - (zs & 0xffff)s00 + borrow;*se = s00 + processed;never executed: *se = s00 + processed; | ||||||||||||||||||||
| borrow = z >> 16; never executed: *se = s00 + processed; | ||||||||||||||||||||
| ; never executed: *se = s00 + processed; | ||||||||||||||||||||
| Storeinc(bx, z, y); never executed: *se = s00 + processed; | ||||||||||||||||||||
| } never executed: *se = s00 + processed; | ||||||||||||||||||||
| while(sx <= sxe); never executed: *se = s00 + processed; | ||||||||||||||||||||
| if (!*bxe) { never executed: *se = s00 + processed; | ||||||||||||||||||||
| bx = b->x; never executed: *se = s00 + processed; | ||||||||||||||||||||
| while(--bxe > bx && !*bxe) never executed: *se = s00 + processed; | ||||||||||||||||||||
| --n; never executed: *se = s00 + processed; | ||||||||||||||||||||
| b->wds = n never executed: *se = s00 + processed;never executed: processed;*se = s00 + processed;never executed: *se = s00 + processed; | ||||||||||||||||||||
| 321 | } | 0 | ||||||||||||||||||
}if (cmp(b, S) >= 0ok
| ||||||||||||||||||||
| 322 | { | 0 | ||||||||||||||||||
| q++; | ||||||||||||||||||||
| borrow = 0; | ||||||||||||||||||||
| carry = 0; | ||||||||||||||||||||
| bx = b->x; | ||||||||||||||||||||
| sx = S->x; | ||||||||||||||||||||
| do { | ||||||||||||||||||||
| si =* never executed: sx++;*ok = nonNullOk;never executed: *ok = nonNullOk; | ||||||||||||||||||||
| ys = (si & 0xffff) + carry; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| zs = (si >> 16) + (ys >> 16); never executed: *ok = nonNullOk; | ||||||||||||||||||||
| carry = zs >> 16; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| y = (*bx & 0xffff) - (ys & 0xffff) + borrow; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| borrow = y >> 16; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| ; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| z = (*bx >> 16) - (zs & 0xffff) + borrow; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| borrow = z >> 16; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| ; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| Storeinc(bx, z, y); never executed: *ok = nonNullOk; | ||||||||||||||||||||
| } never executed: *ok = nonNullOk; | ||||||||||||||||||||
| while(sx <= sxe); never executed: *ok = nonNullOk; | ||||||||||||||||||||
| bx = b->x; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| bxe = bx + n; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| if (!*bxe) { never executed: *ok = nonNullOk; | ||||||||||||||||||||
| while(--bxe > bx && !*bxe) never executed: *ok = nonNullOk; | ||||||||||||||||||||
| --n; never executed: *ok = nonNullOk; | ||||||||||||||||||||
| b->wds never executed: *ok = nonNullOk;never executed: ok = nnonNullOk;*ok = nonNullOk;never executed: *ok = nonNullOk; | ||||||||||||||||||||
| 323 | } | 0 | ||||||||||||||||||
| }return never executed: q;return d;never executed: return d; | ||||||||||||||||||||
| } never executed: return d; | ||||||||||||||||||||
| __attribute__((visibility("default"))) char *qdtoa ( double d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp) never executed: return d; | ||||||||||||||||||||
| { never executed: return d; | ||||||||||||||||||||
| fenv_t envp; never executed: return d; | ||||||||||||||||||||
| feholdexcept(&envp); never executed: return d; | ||||||||||||||||||||
| char *s = _qdtoa( never executed: return d;never executed: d, mode, ndigits, decpt, sign, rve, resultp);return d;never executed: return d; | ||||||||||||||||||||
| fesetenv(&envp); never executed: return d; | ||||||||||||||||||||
| return s never executed: return d;never executed: ;return d;never executed: return d; | ||||||||||||||||||||
| 324 | } | - | ||||||||||||||||||
| 325 | - | |||||||||||||||||||
| static char *_qdtoaQString qdtoa(volatile doubleqreal d, int mode, int ndigits, int *decpt, int *sign, char **rve, char **resultp) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| int bbits, b2, b5, be, dig, i, ieps, ilim0, | ||||||||||||||||||||
| j, j1, k, k0, k_check, leftright, m2, m5, s2, s5, | ||||||||||||||||||||
| try_quick; | ||||||||||||||||||||
| int ilim = 0, ilim1 = 0, spec_case = 0; | ||||||||||||||||||||
| qint32 L;int denorm; | ||||||||||||||||||||
| quint32 x; | ||||||||||||||||||||
| Bigint *b, *b1, *delta, *mhi, *S; | ||||||||||||||||||||
| Bigint *mlo = __null; | ||||||||||||||||||||
| double d2; | ||||||||||||||||||||
| double ds, eps; | ||||||||||||||||||||
| char *s, *s0; | ||||||||||||||||||||
| if (getWord0(d) & 0x80000000) { | ||||||||||||||||||||
| *sign = 1; | ||||||||||||||||||||
| setWord0(&d, getWord0(d) & ~0x80000000); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else*sign= 0; | ||||||||||||||||||||
| if ((getWord0(d) & 0x7ff00000) == 0x7ff00000) | ||||||||||||||||||||
| { | ||||||||||||||||||||
| *decpt = 9999; | ||||||||||||||||||||
| s = | ||||||||||||||||||||
| !getWord1(d) && !(getWord0(d) & 0xfffff) ? const_cast<char*>("Infinity") : | ||||||||||||||||||||
| const_cast<char*>("NaN"); | ||||||||||||||||||||
| if (rve) | ||||||||||||||||||||
| *rve = | ||||||||||||||||||||
| s[3] ? s + 8 : | ||||||||||||||||||||
| s + 3; | ||||||||||||||||||||
| return s; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (d == g_double_zero) | ||||||||||||||||||||
| 327 | { | - | ||||||||||||||||||
| 328 | *decpt = 1; | - | ||||||||||||||||||
| s = const_cast<char*>("0"); | ||||||||||||||||||||
| if (rve) | ||||||||||||||||||||
| *rvebool nonNullSign = s + 1; | ||||||||||||||||||||
| return sfalse; | ||||||||||||||||||||
| 329 | } | - | ||||||||||||||||||
| b = d2b(d, &be, &bbits); | ||||||||||||||||||||
| i = (int )(getWord0(d) >> 20 & (0x7ff00000>>20)); | ||||||||||||||||||||
| if (i != 0) { | ||||||||||||||||||||
| d2 = d; | ||||||||||||||||||||
| setWord0(&d2, getWord0(d2) & 0xfffff); | ||||||||||||||||||||
| setWord0(&d2, getWord0(d2) | 0x3ff00000); | ||||||||||||||||||||
| i -= 1023; | ||||||||||||||||||||
| denorm = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| i = bbits + be + (1023 + (53 -1) - 1); | ||||||||||||||||||||
| x = i > 32 ? getWord0(d) << (64 - i) | getWord1(d) >> (i - 32) | ||||||||||||||||||||
| : getWord1(d) << (32 - i); | ||||||||||||||||||||
| d2 = x; | ||||||||||||||||||||
| setWord0(&d2, getWord0(d2) - 31*0x100000); | ||||||||||||||||||||
| i -= (1023 + (53 -1) - 1) + 1; | ||||||||||||||||||||
| denorm = 1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| dsnonNullDecpt = (d2-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; | ||||||||||||||||||||
| 330 | k =int (ds); | - | ||||||||||||||||||
| if (ds < 0. && ds != k) | ||||||||||||||||||||
| k--; | ||||||||||||||||||||
| k_check = 1; | ||||||||||||||||||||
| if (k >= 0 && k <= 22) { | ||||||||||||||||||||
| if (d < tens[k]) | ||||||||||||||||||||
| k--; | ||||||||||||||||||||
| k_check = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| j = bbits - i - 1; | ||||||||||||||||||||
| if (j >= 0) { | ||||||||||||||||||||
| b2 = 0; | ||||||||||||||||||||
| s2 = j; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| b2 = -j; | ||||||||||||||||||||
| s2 = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (k >= 0) { | ||||||||||||||||||||
| b5 = 0; | ||||||||||||||||||||
| s5 = k; | ||||||||||||||||||||
| s2 += k; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| b2 -= k; | ||||||||||||||||||||
| b5 = -k; | ||||||||||||||||||||
| s5 = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (mode < 0 || mode > 9) | ||||||||||||||||||||
| mode = 0; | ||||||||||||||||||||
| try_quick = 1; | ||||||||||||||||||||
| if (mode > 5) { | ||||||||||||||||||||
| mode -= 4; | ||||||||||||||||||||
| try_quick = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| leftright = 1; | ||||||||||||||||||||
| switch(mode) { | ||||||||||||||||||||
| case 0: | ||||||||||||||||||||
| case 1: | ||||||||||||||||||||
| ilim = ilim1 = -1; | ||||||||||||||||||||
| i = 18; | ||||||||||||||||||||
| ndigits = 0; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| case 2: | ||||||||||||||||||||
| leftright = 0; | ||||||||||||||||||||
| case 4: | ||||||||||||||||||||
| if (ndigits <= 0) | ||||||||||||||||||||
| ndigits = 1; | ||||||||||||||||||||
| ilim = ilim1 = i = ndigits; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| case 3: | ||||||||||||||||||||
| leftright = 0; | ||||||||||||||||||||
| case 5: | ||||||||||||||||||||
| i = ndigits + k + 1; | ||||||||||||||||||||
| ilim = i; | ||||||||||||||||||||
| ilim1length = i - 1; | ||||||||||||||||||||
| if (i <=0) | ||||||||||||||||||||
| i = 1; | ||||||||||||||||||||
| 331 | - | |||||||||||||||||||
| 332 | - | |||||||||||||||||||
| 333 | } | - | ||||||||||||||||||
| try { | ||||||||||||||||||||
| *resultp = static_cast<char *>(malloc(i + 1)); | ||||||||||||||||||||
| do { if (!(*resultp)) qBadAlloc(); } while (0); | ||||||||||||||||||||
| } catch (...) { | ||||||||||||||||||||
| Bfree(b); | ||||||||||||||||||||
| throw; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| s = s0 = *resultp; | ||||||||||||||||||||
| if (ilim >= 0 && ilim <= 14 && try_quick) { | ||||||||||||||||||||
| i = 0; | ||||||||||||||||||||
| d2 = d; | ||||||||||||||||||||
| k0 = k; | ||||||||||||||||||||
| ilim0 = ilim; | ||||||||||||||||||||
| ieps = 2; | ||||||||||||||||||||
| if (k > 0) { | ||||||||||||||||||||
| ds = tens[k&0xf]; | ||||||||||||||||||||
| j = k >> 4; | ||||||||||||||||||||
| if (j & 0x10) { | ||||||||||||||||||||
| j &= 0x10 - 1; | ||||||||||||||||||||
| d /= bigtens[5 -1]; | ||||||||||||||||||||
| ieps++; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| for(; j; j >>= 1, i++) | ||||||||||||||||||||
| if (j & 1) { | ||||||||||||||||||||
| ieps++; | ||||||||||||||||||||
| ds *= bigtens[i]; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| d /= ds; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if ((j1 = -k) != 0) { | ||||||||||||||||||||
| d *= tens[j1 & 0xf]; | ||||||||||||||||||||
| for(j = j1 >> 4; j; j >>= 1, i++) | ||||||||||||||||||||
| if (j & 1) { | ||||||||||||||||||||
| ieps++; | ||||||||||||||||||||
| d *= bigtens[i]; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (k_check && d < 1. && ilim > 0) { | ||||||||||||||||||||
| if (ilim1 <= 0) | ||||||||||||||||||||
| goto fast_failed; | ||||||||||||||||||||
| ilim = ilim1; | ||||||||||||||||||||
| k--; | ||||||||||||||||||||
| d *= 10.; | ||||||||||||||||||||
| ieps++; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| eps = ieps*d + 7.; | ||||||||||||||||||||
| setWord0(&eps, getWord0(eps) - (53 -1)*0x100000); | ||||||||||||||||||||
| if (ilim == 0) { | ||||||||||||||||||||
| S = mhi = 0; | ||||||||||||||||||||
| d -= 5.; | ||||||||||||||||||||
| if (d > eps) | ||||||||||||||||||||
| goto one_digit; | ||||||||||||||||||||
| if (d < -eps) | ||||||||||||||||||||
| goto no_digits; | ||||||||||||||||||||
| goto fast_failed; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (leftright) { | ||||||||||||||||||||
| eps = 0.5/tensresult[ilim-1] - eps; | ||||||||||||||||||||
| for(i = 0;;) { | ||||||||||||||||||||
| L = qint32(d); | ||||||||||||||||||||
| d -= L; | ||||||||||||||||||||
| *s++ = '0'QLocaleData::DoubleMaxSignificant + int(L); | ||||||||||||||||||||
| if (d < eps) | ||||||||||||||||||||
| goto ret1; | ||||||||||||||||||||
| if (1. - d < eps) | ||||||||||||||||||||
| goto bump_up; | ||||||||||||||||||||
| if (++i >= ilim) | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| eps *= 10.; | ||||||||||||||||||||
| d *= 10.; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| eps *= tens[ilim-1]; | ||||||||||||||||||||
| for(i =1;; i++, d *= 10.) { | ||||||||||||||||||||
| L = qint32(d); | ||||||||||||||||||||
| d -= L; | ||||||||||||||||||||
| *s++ = '0' + int(L); | ||||||||||||||||||||
| if (i == ilim) { | ||||||||||||||||||||
| if (d > 0.5 + eps) | ||||||||||||||||||||
| goto bump_up; | ||||||||||||||||||||
| else if (d < 0.5 - eps) { | ||||||||||||||||||||
| while(*--s == '0') {} | ||||||||||||||||||||
| s++; | ||||||||||||||||||||
| goto ret1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| fast_failed: | ||||||||||||||||||||
| s = s0; | ||||||||||||||||||||
| d = d2; | ||||||||||||||||||||
| k = k0; | ||||||||||||||||||||
| ilim = ilim0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (be >= 0 && k <= 14) { | ||||||||||||||||||||
| ds = tens[k]; | ||||||||||||||||||||
| 334 | if (ndigits < 0 && ilim <= 0) { | - | ||||||||||||||||||
| S = mhi = 0; | ||||||||||||||||||||
| if (ilim < 0 || d <= 5*ds) | ||||||||||||||||||||
| goto no_digits; | ||||||||||||||||||||
| goto one_digit; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| for(i = 1;; i++) { | ||||||||||||||||||||
| L = qint32(d / ds); | ||||||||||||||||||||
| d -= L*ds; | ||||||||||||||||||||
| *s++ = '0' + int(L); | ||||||||||||||||||||
| if (i == ilim) { | ||||||||||||||||||||
| d += d; | ||||||||||||||||||||
| if (d > ds || (d == ds && L & 1)) { | ||||||||||||||||||||
| bump_up: | ||||||||||||||||||||
| while(*--s == '9') | ||||||||||||||||||||
| ifdoubleToAscii(s == s0) { | ||||||||||||||||||||
| k++; | ||||||||||||||||||||
| *s = '0'; | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| ++*s++; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if ((d*= 10.) == g_double_zero) | ||||||||||||||||||||
| break; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| goto ret1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| m2 = b2; | ||||||||||||||||||||
| m5 = b5; | ||||||||||||||||||||
| mhi = mlo = 0; | ||||||||||||||||||||
| if (leftright) { | ||||||||||||||||||||
| if (mode < 2) { | ||||||||||||||||||||
| i = | ||||||||||||||||||||
| denorm ? be + (1023 + (53 -1) - 1 + 1) : | ||||||||||||||||||||
| 1 + 53 - bbits; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| j = ilim - 1; | ||||||||||||||||||||
| if (m5 >= j) | ||||||||||||||||||||
| m5 -= j; | ||||||||||||||||||||
| else { | ||||||||||||||||||||
| s5 += j -= m5; | ||||||||||||||||||||
| b5 += j; | ||||||||||||||||||||
| m5 = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if ((i = ilim) < 0) { | ||||||||||||||||||||
| m2 -= i; | ||||||||||||||||||||
| i = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| b2 += i; | ||||||||||||||||||||
| s2 += i; | ||||||||||||||||||||
| mhi = i2b(1); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (m2 > 0 && s2 > 0) { | ||||||||||||||||||||
| i = m2 < s2 ? m2 : s2; | ||||||||||||||||||||
| b2 -= i; | ||||||||||||||||||||
| m2 -= i; | ||||||||||||||||||||
| s2 -= i; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (b5 > 0) { | ||||||||||||||||||||
| if (leftright) { | ||||||||||||||||||||
| if (m5 > 0) { | ||||||||||||||||||||
| mhi = pow5mult(mhi, m5); | ||||||||||||||||||||
| b1 = mult(mhi, b); | ||||||||||||||||||||
| Bfree(b); | ||||||||||||||||||||
| b = b1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if ((j = b5 - m5) != 0) | ||||||||||||||||||||
| b = pow5mult(bQLocaleData::DFSignificantDigits, j); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| b = pow5mult(bQLocale::FloatingPointShortest, b5); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| S = i2b(1); | ||||||||||||||||||||
| if (s5 > 0) | ||||||||||||||||||||
| S = pow5mult(Sresult, | ||||||||||||||||||||
| 335 | s5); | - | ||||||||||||||||||
| if (mode < 2) { | ||||||||||||||||||||
| if (!getWord1(d) && !(getWord0(d) & 0xfffff) | ||||||||||||||||||||
| && getWord0(d) & 0x7ff00000 | ||||||||||||||||||||
| ) { | ||||||||||||||||||||
| b2 += 1; | ||||||||||||||||||||
| s2 += 1; | ||||||||||||||||||||
| spec_case = 1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| spec_case = 0; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if ((i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1)QLocaleData::DoubleMaxSignificant + s2) & 0x1f) != 0) | ||||||||||||||||||||
| i = 32 - i; | ||||||||||||||||||||
| if (i > 4) { | ||||||||||||||||||||
| i -= 4; | ||||||||||||||||||||
| b2 += i; | ||||||||||||||||||||
| m2 += i; | ||||||||||||||||||||
| s2 += i; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else if (i < 4) { | ||||||||||||||||||||
| i += 28; | ||||||||||||||||||||
| b2 += i; | ||||||||||||||||||||
| m2 += i; | ||||||||||||||||||||
| s2 += i; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (b2 > 0) | ||||||||||||||||||||
| b = lshift(b, b2); | ||||||||||||||||||||
| if (s2 > 0) | ||||||||||||||||||||
| S = lshift(S, s2); | ||||||||||||||||||||
| if (k_check) { | ||||||||||||||||||||
| if (cmp(b,S) < 0) { | ||||||||||||||||||||
| k--; | ||||||||||||||||||||
| b = multadd(b, 10, 0); | ||||||||||||||||||||
| if (leftright) | ||||||||||||||||||||
| mhi = multadd(mhi, 10, 0); | ||||||||||||||||||||
| ilim = ilim1; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (ilim <= 0 && mode > 2) { | ||||||||||||||||||||
| if (ilim < 0 || cmp(b,S = multadd(S1, 5nonNullSign, 0)) <= 0) { | ||||||||||||||||||||
| no_digits: | ||||||||||||||||||||
| k = -1 - ndigits; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| one_digit: | ||||||||||||||||||||
| *s++ = '1'; | ||||||||||||||||||||
| k++; | ||||||||||||||||||||
| goto ret; | ||||||||||||||||||||
| } | ||||||||||||||||||||
| if (leftright) { | ||||||||||||||||||||
| if (m2 > 0) | ||||||||||||||||||||
| mhi = lshift(mhilength, m2nonNullDecpt); | ||||||||||||||||||||
| 336 | - | |||||||||||||||||||
| 337 | mlo = mhi;if (spec_case) { | 0 | ||||||||||||||||||
| mhi = Balloc(mhi->k); | ||||||||||||||||||||
memcpy(reinterpret_cast<char *>(&mhi->sign), reinterpret_cast<char *>(&mlo->sign), mlo->wds*sizeof(qint32
| ||||||||||||||||||||
| 338 | + 2* never executed: sizeof(int));*sign = nonNullSign ? 1 : 0;never executed: *sign = nonNullSign ? 1 : 0; | 0 | ||||||||||||||||||
| mhi = lshift(mhi, 1); never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| } never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| for(i = 1;;i++) { never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| dig = quorem(b,S) + '0'; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| j = cmp(b, mlo); never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| delta = diff(S, mhi); never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| j1 = delta-> never executed: *sign = nonNullSign ? 1 : 0;never executed: sign = nonNullSign*sign = nonNullSign ? 1 : 0;
never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| Bfree(delta); never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if (j1 == 0 && !mode && !(getWord1(d) & 1)) { never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if (dig == '9') never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| goto round_9_up; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if (j > 0) never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| dig++; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| *s++ = dig; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| goto ret; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| } never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if (j < 0 || (j == 0 && !mode never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| && !(getWord1(d) & 1) never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| )) { never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if (j1 > 0) { never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| b = lshift(b, 1); never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| j1 = cmp(b, S); never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if ((j1 > 0 || (j1 == 0 && dig & 1)) never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| && dig++ == '9') never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| goto round_9_up; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| } never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| *s++ = dig; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| goto ret; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| } never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if (j1 > never executed: *sign = nonNullSign ? 1 : 0;never executed: 0) {*sign = nonNullSign ? 1 : 0;never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if (dig == '9') { never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| round_9_up: never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| *s++ = '9'; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| goto roundoff; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| } never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| *s++ = dig + 1; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| goto ret; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| } never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| *s++ = dig; never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| if (i == ilim) never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| break never executed: *sign = nonNullSign ? 1 : 0;never executed: ;*sign = nonNullSign ? 1 : 0;never executed: *sign = nonNullSign ? 1 : 0; | ||||||||||||||||||||
| 339 | b = multadd(b, 10, 0);if (mlo == mhidecpt
| 0 | ||||||||||||||||||
| 340 | mlo = mhi = multadd(mhi, 10, 0); | 0 | ||||||||||||||||||
| else { | ||||||||||||||||||||
| mlo = multadd(mlo, 10, 0); | ||||||||||||||||||||
| mhi = multadd(mhi, 10, 0); | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| } | ||||||||||||||||||||
| else | ||||||||||||||||||||
| for(i = 1;; i++) {* never executed: s++ = digdecpt = quorem(b,S) + '0';*decpt = nonNullDecpt;never executed: *decpt = nonNullDecpt; | ||||||||||||||||||||
| if (i >= ilim) never executed: *decpt = nonNullDecpt; | ||||||||||||||||||||
| break never executed: *decpt = nonNullDecpt;never executed: nonNullDecpt;*decpt = nonNullDecpt;never executed: *decpt = nonNullDecpt; | ||||||||||||||||||||
| 341 | - | |||||||||||||||||||
| 342 | b = multadd(b, 10, 0); | 0 | ||||||||||||||||||
| } | ||||||||||||||||||||
| b = lshift(b, 1); | ||||||||||||||||||||
| j = cmpreturn never executed: return QLatin1String(result, length);never executed: QLatin1String(bresult, S);return QLatin1String(result, length);never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| if (j > 0 || (j == 0 && dig & 1)) { never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| roundoff: never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| while(*--s == '9') never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| if (s == s0) { never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| k++; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| *s++ = '1'; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| goto ret; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| } never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| ++*s++; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| } never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| else { never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| while(*--s == '0') {} never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| s++; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| } never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| ret: never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| Bfree(S); never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| if (mhi) { never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| if (mlo && mlo != mhi) never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| Bfree(mlo); never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| Bfree(mhi); never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| } never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| ret1: never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| Bfree(b never executed: return QLatin1String(result, length);never executed: length);if (s == s0) {return QLatin1String(result, length);never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| *s++ = '0'; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| k = 0; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| } never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| *s = 0; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| *decpt = k + 1; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| if (rve) never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| *rve = s; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| return s0; never executed: return QLatin1String(result, length); | ||||||||||||||||||||
| 343 | } | - | ||||||||||||||||||
| 344 | - | |||||||||||||||||||
| 345 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |