clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name decimal-to-binary.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -analyzer-config-compatibility-mode=true -mrelocation-model pic -pic-level 2 -mframe-pointer=none -relaxed-aliasing -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -ffunction-sections -fdata-sections -fcoverage-compilation-dir=/build/source/build-llvm/tools/clang/stage2-bins -resource-dir /usr/lib/llvm-17/lib/clang/17 -isystem /build/source/llvm/../mlir/include -isystem tools/mlir/include -isystem tools/clang/include -isystem /build/source/llvm/../clang/include -D FLANG_INCLUDE_TESTS=1 -D FLANG_LITTLE_ENDIAN=1 -D FLANG_VENDOR="Debian " -D _DEBUG -D _GLIBCXX_ASSERTIONS -D _GNU_SOURCE -D _LIBCPP_ENABLE_ASSERTIONS -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D __STDC_LIMIT_MACROS -I tools/flang/lib/Decimal -I /build/source/flang/lib/Decimal -I /build/source/flang/include -I tools/flang/include -I include -I /build/source/llvm/include -D _FORTIFY_SOURCE=2 -D NDEBUG -U _GLIBCXX_ASSERTIONS -U NDEBUG -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/x86_64-linux-gnu/c++/10 -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../include/c++/10/backward -internal-isystem /usr/lib/llvm-17/lib/clang/17/include -internal-isystem /usr/local/include -internal-isystem /usr/lib/gcc/x86_64-linux-gnu/10/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -fmacro-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fmacro-prefix-map=/build/source/= -fcoverage-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fcoverage-prefix-map=/build/source/= -source-date-epoch 1683717183 -O2 -Wno-unused-command-line-argument -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-maybe-uninitialized -Wno-class-memaccess -Wno-redundant-move -Wno-pessimizing-move -Wno-noexcept-type -Wno-comment -Wno-misleading-indentation -Wno-deprecated-copy -Wno-ctad-maybe-unsupported -std=c++17 -fdeprecated-macro -fdebug-compilation-dir=/build/source/build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/source/build-llvm/tools/clang/stage2-bins=build-llvm/tools/clang/stage2-bins -fdebug-prefix-map=/build/source/= -ferror-limit 19 -fvisibility-inlines-hidden -stack-protector 2 -fgnuc-version=4.2.1 -fcolor-diagnostics -vectorize-loops -vectorize-slp -analyzer-output=html -analyzer-config stable-report-filename=true -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /tmp/scan-build-2023-05-10-133810-16478-1 -x c++ /build/source/flang/lib/Decimal/decimal-to-binary.cpp
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | #include "big-radix-floating-point.h" |
| 10 | #include "flang/Common/bit-population-count.h" |
| 11 | #include "flang/Common/leading-zero-bit-count.h" |
| 12 | #include "flang/Decimal/binary-floating-point.h" |
| 13 | #include "flang/Decimal/decimal.h" |
| 14 | #include <cinttypes> |
| 15 | #include <cstring> |
| 16 | #include <ctype.h> |
| 17 | |
| 18 | namespace Fortran::decimal { |
| 19 | |
| 20 | template <int PREC, int LOG10RADIX> |
| 21 | bool BigRadixFloatingPointNumber<PREC, LOG10RADIX>::ParseNumber( |
| 22 | const char *&p, bool &inexact, const char *end) { |
| 23 | SetToZero(); |
| 24 | if (end && p >= end) { |
| 25 | return false; |
| 26 | } |
| 27 | |
| 28 | for (; p != end && *p == ' '; ++p) { |
| 29 | } |
| 30 | if (p == end) { |
| 31 | return false; |
| 32 | } |
| 33 | const char *q{p}; |
| 34 | isNegative_ = *q == '-'; |
| 35 | if (*q == '-' || *q == '+') { |
| 36 | ++q; |
| 37 | } |
| 38 | const char *start{q}; |
| 39 | for (; q != end && *q == '0'; ++q) { |
| 40 | } |
| 41 | const char *firstDigit{q}; |
| 42 | for (; q != end && *q >= '0' && *q <= '9'; ++q) { |
| 43 | } |
| 44 | const char *point{nullptr}; |
| 45 | if (q != end && *q == '.') { |
| 46 | point = q; |
| 47 | for (++q; q != end && *q >= '0' && *q <= '9'; ++q) { |
| 48 | } |
| 49 | } |
| 50 | if (q == start || (q == start + 1 && start == point)) { |
| 51 | return false; |
| 52 | } |
| 53 | |
| 54 | |
| 55 | p = q; |
| 56 | |
| 57 | if (point) { |
| 58 | while (q[-1] == '0') { |
| 59 | --q; |
| 60 | } |
| 61 | if (q[-1] == '.') { |
| 62 | point = nullptr; |
| 63 | --q; |
| 64 | } |
| 65 | } |
| 66 | if (!point) { |
| 67 | while (q > firstDigit && q[-1] == '0') { |
| 68 | --q; |
| 69 | ++exponent_; |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | const char *limit{firstDigit + maxDigits * log10Radix + (point != nullptr)}; |
| 74 | if (q > limit) { |
| 75 | inexact = true; |
| 76 | if (point >= limit) { |
| 77 | q = point; |
| 78 | point = nullptr; |
| 79 | } |
| 80 | if (!point) { |
| 81 | exponent_ += q - limit; |
| 82 | } |
| 83 | q = limit; |
| 84 | } |
| 85 | if (point) { |
| 86 | exponent_ -= static_cast<int>(q - point - 1); |
| 87 | } |
| 88 | if (q == firstDigit) { |
| 89 | exponent_ = 0; |
| 90 | } |
| 91 | |
| 92 | for (auto times{radix}; q-- > firstDigit;) { |
| 93 | if (*q != '.') { |
| 94 | if (times == radix) { |
| 95 | digit_[digits_++] = *q - '0'; |
| 96 | times = 10; |
| 97 | } else { |
| 98 | digit_[digits_ - 1] += times * (*q - '0'); |
| 99 | times *= 10; |
| 100 | } |
| 101 | } |
| 102 | } |
| 103 | |
| 104 | if (p == end) { |
| 105 | return true; |
| 106 | } |
| 107 | q = p; |
| 108 | switch (*q) { |
| 109 | case 'e': |
| 110 | case 'E': |
| 111 | case 'd': |
| 112 | case 'D': |
| 113 | case 'q': |
| 114 | case 'Q': { |
| 115 | if (++q == end) { |
| 116 | break; |
| 117 | } |
| 118 | bool negExpo{*q == '-'}; |
| 119 | if (*q == '-' || *q == '+') { |
| 120 | ++q; |
| 121 | } |
| 122 | if (q != end && *q >= '0' && *q <= '9') { |
| 123 | int expo{0}; |
| 124 | for (; q != end && *q == '0'; ++q) { |
| 125 | } |
| 126 | const char *expDig{q}; |
| 127 | for (; q != end && *q >= '0' && *q <= '9'; ++q) { |
| 128 | expo = 10 * expo + *q - '0'; |
| 129 | } |
| 130 | if (q >= expDig + 8) { |
| 131 | |
| 132 | |
| 133 | |
| 134 | |
| 135 | expo = 10 * Real::decimalRange; |
| 136 | exponent_ = 0; |
| 137 | } |
| 138 | p = q; |
| 139 | if (negExpo) { |
| 140 | exponent_ -= expo; |
| 141 | } else { |
| 142 | exponent_ += expo; |
| 143 | } |
| 144 | } |
| 145 | } break; |
| 146 | default: |
| 147 | break; |
| 148 | } |
| 149 | return true; |
| 150 | } |
| 151 | |
| 152 | template <int PREC, int LOG10RADIX> |
| 153 | void BigRadixFloatingPointNumber<PREC, |
| 154 | LOG10RADIX>::LoseLeastSignificantDigit() { |
| 155 | Digit LSD{digit_[0]}; |
| 156 | for (int j{0}; j < digits_ - 1; ++j) { |
| 157 | digit_[j] = digit_[j + 1]; |
| 158 | } |
| 159 | digit_[digits_ - 1] = 0; |
| 160 | bool incr{false}; |
| 161 | switch (rounding_) { |
| 162 | case RoundNearest: |
| 163 | incr = LSD > radix / 2 || (LSD == radix / 2 && digit_[0] % 2 != 0); |
| 164 | break; |
| 165 | case RoundUp: |
| 166 | incr = LSD > 0 && !isNegative_; |
| 167 | break; |
| 168 | case RoundDown: |
| 169 | incr = LSD > 0 && isNegative_; |
| 170 | break; |
| 171 | case RoundToZero: |
| 172 | break; |
| 173 | case RoundCompatible: |
| 174 | incr = LSD >= radix / 2; |
| 175 | break; |
| 176 | } |
| 177 | for (int j{0}; (digit_[j] += incr) == radix; ++j) { |
| 178 | digit_[j] = 0; |
| 179 | } |
| 180 | } |
| 181 | |
| 182 | |
| 183 | |
| 184 | |
| 185 | |
| 186 | template <int PREC> class IntermediateFloat { |
| 187 | public: |
| 188 | static constexpr int precision{PREC}; |
| 189 | using IntType = common::HostUnsignedIntType<precision>; |
| 190 | static constexpr IntType topBit{IntType{1} << (precision - 1)}; |
| 191 | static constexpr IntType mask{topBit + (topBit - 1)}; |
| 192 | |
| 193 | IntermediateFloat() {} |
| 194 | IntermediateFloat(const IntermediateFloat &) = default; |
| 195 | |
| 196 | |
| 197 | |
| 198 | template <typename UINT> bool SetTo(UINT n) { |
| 199 | static constexpr int nBits{CHAR_BIT * sizeof n}; |
| 200 | if constexpr (precision >= nBits) { |
| 201 | value_ = n; |
| 202 | guard_ = 0; |
| 203 | return 0; |
| 204 | } else { |
| 205 | int shift{common::BitsNeededFor(n) - precision}; |
| 206 | if (shift <= 0) { |
| 207 | value_ = n; |
| 208 | guard_ = 0; |
| 209 | return 0; |
| 210 | } else { |
| 211 | value_ = n >> shift; |
| 212 | exponent_ += shift; |
| 213 | n <<= nBits - shift; |
| 214 | guard_ = (n >> (nBits - guardBits)) | ((n << guardBits) != 0); |
| 215 | return shift; |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | void ShiftIn(int bit = 0) { value_ = value_ + value_ + bit; } |
| 221 | bool IsFull() const { return value_ >= topBit; } |
| 222 | void AdjustExponent(int by) { exponent_ += by; } |
| 223 | void SetGuard(int g) { |
| 224 | guard_ |= (static_cast<GuardType>(g & 6) << (guardBits - 3)) | (g & 1); |
| 225 | } |
| 226 | |
| 227 | ConversionToBinaryResult<PREC> ToBinary( |
| 228 | bool isNegative, FortranRounding) const; |
| 229 | |
| 230 | private: |
| 231 | static constexpr int guardBits{3}; |
| 232 | using GuardType = int; |
| 233 | static constexpr GuardType oneHalf{GuardType{1} << (guardBits - 1)}; |
| 234 | |
| 235 | IntType value_{0}; |
| 236 | GuardType guard_{0}; |
| 237 | int exponent_{0}; |
| 238 | }; |
| 239 | |
| 240 | template <int PREC> |
| 241 | ConversionToBinaryResult<PREC> IntermediateFloat<PREC>::ToBinary( |
| 242 | bool isNegative, FortranRounding rounding) const { |
| 243 | using Binary = BinaryFloatingPointNumber<PREC>; |
| 244 | |
| 245 | |
| 246 | IntType fraction{value_}; |
| 247 | GuardType guard{guard_}; |
| 248 | int expo{exponent_ + Binary::exponentBias + (precision - 1)}; |
| 249 | while (expo < 1 && (fraction > 0 || guard > oneHalf)) { |
| 250 | guard = (guard & 1) | (guard >> 1) | |
| 251 | ((static_cast<GuardType>(fraction) & 1) << (guardBits - 1)); |
| 252 | fraction >>= 1; |
| 253 | ++expo; |
| 254 | } |
| 255 | int flags{Exact}; |
| 256 | if (guard != 0) { |
| 257 | flags |= Inexact; |
| 258 | } |
| 259 | if (fraction == 0 && guard <= oneHalf) { |
| 260 | return {Binary{}, static_cast<enum ConversionResultFlags>(flags)}; |
| 261 | } |
| 262 | |
| 263 | while (fraction < topBit && expo > 1) { |
| 264 | --expo; |
| 265 | fraction = fraction * 2 + (guard >> (guardBits - 2)); |
| 266 | guard = (((guard >> (guardBits - 2)) & 1) << (guardBits - 1)) | (guard & 1); |
| 267 | } |
| 268 | |
| 269 | bool incr{false}; |
| 270 | switch (rounding) { |
| 271 | case RoundNearest: |
| 272 | incr = guard > oneHalf || (guard == oneHalf && (fraction & 1)); |
| 273 | break; |
| 274 | case RoundUp: |
| 275 | incr = guard != 0 && !isNegative; |
| 276 | break; |
| 277 | case RoundDown: |
| 278 | incr = guard != 0 && isNegative; |
| 279 | break; |
| 280 | case RoundToZero: |
| 281 | break; |
| 282 | case RoundCompatible: |
| 283 | incr = guard >= oneHalf; |
| 284 | break; |
| 285 | } |
| 286 | if (incr) { |
| 287 | if (fraction == mask) { |
| 288 | |
| 289 | ++expo; |
| 290 | fraction = topBit; |
| 291 | } else { |
| 292 | ++fraction; |
| 293 | } |
| 294 | } |
| 295 | if (expo == 1 && fraction < topBit) { |
| 296 | expo = 0; |
| 297 | } |
| 298 | if (expo >= Binary::maxExponent) { |
| 299 | expo = Binary::maxExponent; |
| 300 | flags |= Overflow; |
| 301 | fraction = 0; |
| 302 | } |
| 303 | using Raw = typename Binary::RawType; |
| 304 | Raw raw = static_cast<Raw>(isNegative) << (Binary::bits - 1); |
| 305 | raw |= static_cast<Raw>(expo) << Binary::significandBits; |
| 306 | if constexpr (Binary::isImplicitMSB) { |
| 307 | fraction &= ~topBit; |
| 308 | } |
| 309 | raw |= fraction; |
| 310 | return {Binary(raw), static_cast<enum ConversionResultFlags>(flags)}; |
| 311 | } |
| 312 | |
| 313 | template <int PREC, int LOG10RADIX> |
| 314 | ConversionToBinaryResult<PREC> |
| 315 | BigRadixFloatingPointNumber<PREC, LOG10RADIX>::ConvertToBinary() { |
| 316 | |
| 317 | |
| 318 | |
| 319 | Normalize(); |
| 320 | if (digits_ == 0) { |
| 321 | return {Real{SignBit()}}; |
| 322 | } |
| 323 | |
| 324 | |
| 325 | |
| 326 | exponent_ += digits_ * log10Radix; |
| 327 | |
| 328 | static constexpr int crazy{2 * Real::decimalRange + log10Radix}; |
| 329 | if (exponent_ < -crazy) { |
| 330 | return {Real{SignBit()}, Inexact}; |
| 331 | } else if (exponent_ > crazy) { |
| 332 | return {Real{Infinity()}, Overflow}; |
| 333 | } |
| 334 | |
| 335 | |
| 336 | IntermediateFloat<PREC> f; |
| 337 | while (exponent_ < log10Radix) { |
| 338 | |
| 339 | f.AdjustExponent(-9); |
| 340 | digitLimit_ = digits_; |
| 341 | if (int carry{MultiplyWithoutNormalization<512>()}) { |
| 342 | |
| 343 | PushCarry(carry); |
| 344 | exponent_ += log10Radix; |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | |
| 349 | |
| 350 | while (exponent_ > log10Radix) { |
| 351 | digitLimit_ = digits_; |
| 352 | int carry; |
| 353 | if (exponent_ >= log10Radix + 4) { |
| 354 | |
| 355 | exponent_ -= 4; |
| 356 | carry = MultiplyWithoutNormalization<(5 * 5 * 5 * 5)>(); |
| 357 | f.AdjustExponent(4); |
| 358 | } else { |
| 359 | |
| 360 | --exponent_; |
| 361 | carry = MultiplyWithoutNormalization<5>(); |
| 362 | f.AdjustExponent(1); |
| 363 | } |
| 364 | if (carry != 0) { |
| 365 | |
| 366 | PushCarry(carry); |
| 367 | exponent_ += log10Radix; |
| 368 | } |
| 369 | } |
| 370 | |
| 371 | |
| 372 | |
| 373 | |
| 374 | int guardShift{f.SetTo(digit_[--digits_])}; |
| 375 | |
| 376 | digitLimit_ = digits_; |
| 377 | while (!f.IsFull()) { |
| 378 | |
| 379 | f.AdjustExponent(-1); |
| 380 | std::uint32_t carry = MultiplyWithoutNormalization<2>(); |
| 381 | f.ShiftIn(carry); |
| 382 | } |
| 383 | |
| 384 | |
| 385 | int guard{0}; |
| 386 | if (guardShift == 0) { |
| 387 | guard = MultiplyWithoutNormalization<4>(); |
| 388 | } else if (guardShift == 1) { |
| 389 | guard = MultiplyWithoutNormalization<2>(); |
| 390 | } |
| 391 | guard = guard + guard + !IsZero(); |
| 392 | f.SetGuard(guard); |
| 393 | return f.ToBinary(isNegative_, rounding_); |
| 394 | } |
| 395 | |
| 396 | template <int PREC, int LOG10RADIX> |
| 397 | ConversionToBinaryResult<PREC> |
| 398 | BigRadixFloatingPointNumber<PREC, LOG10RADIX>::ConvertToBinary( |
| 399 | const char *&p, const char *limit) { |
| 400 | bool inexact{false}; |
| 401 | if (ParseNumber(p, inexact, limit)) { |
| |
| 402 | auto result{ConvertToBinary()}; |
| 403 | if (inexact) { |
| 404 | result.flags = |
| 405 | static_cast<enum ConversionResultFlags>(result.flags | Inexact); |
| 406 | } |
| 407 | return result; |
| 408 | } else { |
| 409 | |
| 410 | |
| 411 | |
| 412 | const char *q{p}; |
| 4 | | 'q' initialized to a null pointer value | |
|
| 413 | if (!limit || q < limit) { |
| 414 | isNegative_ = *q == '-'; |
| 5 | | Dereference of null pointer (loaded from variable 'q') |
|
| 415 | if (isNegative_ || *q == '+') { |
| 416 | ++q; |
| 417 | } |
| 418 | } |
| 419 | if ((!limit || limit >= q + 3) && toupper(q[0]) == 'N' && |
| 420 | toupper(q[1]) == 'A' && toupper(q[2]) == 'N') { |
| 421 | |
| 422 | p = q + 3; |
| 423 | bool isQuiet{true}; |
| 424 | if ((!limit || p < limit) && *p == '(') { |
| 425 | int depth{1}; |
| 426 | do { |
| 427 | ++p; |
| 428 | if (limit && p >= limit) { |
| 429 | |
| 430 | return {Real{NaN(false)}, Invalid}; |
| 431 | } else if (*p == '(') { |
| 432 | ++depth; |
| 433 | } else if (*p == ')') { |
| 434 | --depth; |
| 435 | } else if (*p != ' ') { |
| 436 | |
| 437 | |
| 438 | } |
| 439 | } while (depth > 0); |
| 440 | ++p; |
| 441 | } |
| 442 | return {Real{NaN(isQuiet)}}; |
| 443 | } else { |
| 444 | if ((!limit || limit >= q + 3) && toupper(q[0]) == 'I' && |
| 445 | toupper(q[1]) == 'N' && toupper(q[2]) == 'F') { |
| 446 | if ((!limit || limit >= q + 8) && toupper(q[3]) == 'I' && |
| 447 | toupper(q[4]) == 'N' && toupper(q[5]) == 'I' && |
| 448 | toupper(q[6]) == 'T' && toupper(q[7]) == 'Y') { |
| 449 | p = q + 8; |
| 450 | } else { |
| 451 | p = q + 3; |
| 452 | } |
| 453 | return {Real{Infinity()}}; |
| 454 | } else { |
| 455 | |
| 456 | return {Real{NaN()}, Invalid}; |
| 457 | } |
| 458 | } |
| 459 | } |
| 460 | } |
| 461 | |
| 462 | template <int PREC> |
| 463 | ConversionToBinaryResult<PREC> ConvertToBinary( |
| 464 | const char *&p, enum FortranRounding rounding, const char *end) { |
| 465 | return BigRadixFloatingPointNumber<PREC>{rounding}.ConvertToBinary(p, end); |
| 2 | | Calling 'BigRadixFloatingPointNumber::ConvertToBinary' | |
|
| 466 | } |
| 467 | |
| 468 | template ConversionToBinaryResult<8> ConvertToBinary<8>( |
| 469 | const char *&, enum FortranRounding, const char *end); |
| 470 | template ConversionToBinaryResult<11> ConvertToBinary<11>( |
| 471 | const char *&, enum FortranRounding, const char *end); |
| 472 | template ConversionToBinaryResult<24> ConvertToBinary<24>( |
| 473 | const char *&, enum FortranRounding, const char *end); |
| 474 | template ConversionToBinaryResult<53> ConvertToBinary<53>( |
| 475 | const char *&, enum FortranRounding, const char *end); |
| 476 | template ConversionToBinaryResult<64> ConvertToBinary<64>( |
| 477 | const char *&, enum FortranRounding, const char *end); |
| 478 | template ConversionToBinaryResult<113> ConvertToBinary<113>( |
| 479 | const char *&, enum FortranRounding, const char *end); |
| 480 | |
| 481 | extern "C" { |
| 482 | enum ConversionResultFlags ConvertDecimalToFloat( |
| 483 | const char **p, float *f, enum FortranRounding rounding) { |
| 484 | auto result{Fortran::decimal::ConvertToBinary<24>(*p, rounding)}; |
| 485 | std::memcpy(reinterpret_cast<void *>(f), |
| 486 | reinterpret_cast<const void *>(&result.binary), sizeof *f); |
| 487 | return result.flags; |
| 488 | } |
| 489 | enum ConversionResultFlags ConvertDecimalToDouble( |
| 490 | const char **p, double *d, enum FortranRounding rounding) { |
| 491 | auto result{Fortran::decimal::ConvertToBinary<53>(*p, rounding)}; |
| 492 | std::memcpy(reinterpret_cast<void *>(d), |
| 493 | reinterpret_cast<const void *>(&result.binary), sizeof *d); |
| 494 | return result.flags; |
| 495 | } |
| 496 | enum ConversionResultFlags ConvertDecimalToLongDouble( |
| 497 | const char **p, long double *ld, enum FortranRounding rounding) { |
| 498 | auto result{Fortran::decimal::ConvertToBinary<64>(*p, rounding)}; |
| 1 | Calling 'ConvertToBinary<64>' | |
|
| 499 | std::memcpy(reinterpret_cast<void *>(ld), |
| 500 | reinterpret_cast<const void *>(&result.binary), sizeof *ld); |
| 501 | return result.flags; |
| 502 | } |
| 503 | } |
| 504 | } |