Skip to content

Commit bb5ce00

Browse files
committed
Something better.
1 parent deaa74d commit bb5ce00

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

src/generic/stage2/numberparsing.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
namespace stage2 {
22
namespace numberparsing {
3-
#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
4-
#warning "Your floating-point rounding default is inadequate and may lead to inexact parsing."
5-
#endif
3+
64
// Attempts to compute i * 10^(power) exactly; and if "negative" is
75
// true, negate the result.
86
// This function will only work in some cases, when it does not work, success is
@@ -15,7 +13,12 @@ really_inline double compute_float_64(int64_t power, uint64_t i, bool negative,
1513
// It was described in
1614
// Clinger WD. How to read floating point numbers accurately.
1715
// ACM SIGPLAN Notices. 1990
16+
#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
17+
// We cannot be certain that x/y is rounded to nearest.
18+
if (0 <= power && power <= 22 && i <= 9007199254740991) {
19+
#else
1820
if (-22 <= power && power <= 22 && i <= 9007199254740991) {
21+
#endif
1922
// convert the integer into a double. This is lossless since
2023
// 0 <= i <= 2^53 - 1.
2124
double d = double(i);

tests/numberparsingcheck.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -208,12 +208,6 @@ bool validate(const char *dirname) {
208208
}
209209

210210
int main(int argc, char *argv[]) {
211-
#if (FLT_EVAL_METHOD != 1) && (FLT_EVAL_METHOD != 0)
212-
std::cout << "Your floating-point rounding default is inadequate and may lead to inexact parsing." << std::endl;
213-
std::cout << "We are not going to check number parsing precision." << std::endl;
214-
std::cout << "We are returning with a success condition nevertheless (to avoid noisy failing tests)." << std::endl;
215-
return EXIT_SUCCESS;
216-
#endif
217211
if (argc != 2) {
218212
std::cerr << "Usage: " << argv[0] << " <directorywithjsonfiles>"
219213
<< std::endl;

0 commit comments

Comments
 (0)