Skip to content

Commit dcd915b

Browse files
author
Daniel Lemire
committed
minor tweaking
1 parent 6a4537a commit dcd915b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

benchmarks/exhaustivefloat32.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,7 @@ void run_exhaustive32(bool errol) {
7676
std::span<char> bufRef(buf1, sizeof(buf1)), bufAlgo(buf2, sizeof(buf2));
7777
fmt::print("# processing {}", algo.name);
7878
fflush(stdout);
79-
for(size_t i = 0; i < 1; i++) {
80-
//for (uint64_t i = 0; i < (1ULL << 32); ++i) {
79+
for (uint64_t i = 0; i < (1ULL << 32); ++i) {
8180
if (i % 0x2000000 == 0) {
8281
printf(".");
8382
fflush(stdout);
@@ -86,13 +85,10 @@ void run_exhaustive32(bool errol) {
8685
uint32_t i32(i);
8786
float d;
8887
std::memcpy(&d, &i32, sizeof(float));
89-
d = 33554448;
9088
if (std::isnan(d) || std::isinf(d))
9189
continue;
9290
// Reference output
9391
const size_t vRef = Benchmarks::std_to_chars(d, bufRef);
94-
d = 33554448;
95-
9692
const size_t vAlgo = algo.func(d, bufAlgo);
9793

9894
std::string_view svRef{bufRef.data(), vRef};
@@ -109,15 +105,18 @@ void run_exhaustive32(bool errol) {
109105
fflush(stdout);
110106
break;
111107
}
108+
if(*backRef != d || *backAlgo != d) {
109+
fmt::println("\n# Error: parsing the output with std::from_chars does not bring back the input.");
110+
}
112111
if(*backRef != d) {
113112
incorrect = true;
114-
fmt::print(" mismatch: d = {}, backRef = {}", d, *backRef);
113+
fmt::print(" ref mismatch: d = {}, backRef = {}", d, *backRef);
115114
fflush(stdout);
116115
break;
117116
}
118117
if(*backAlgo != d) {
119118
incorrect = true;
120-
fmt::print(" mismatch: d = {}, backAlgo = {}", d, *backAlgo);
119+
fmt::print(" algo mismatch: d = {}, backAlgo = {}, parsing the output with std::from_chars does not recover the original", d, *backAlgo);
121120
fflush(stdout);
122121
break;
123122
}

0 commit comments

Comments
 (0)