formatting

This commit is contained in:
Daniel Lemire 2024-08-31 18:27:44 -04:00
parent c8abf94560
commit 9117ec4f69

View File

@ -78,25 +78,37 @@ constexpr double constexptest() { return parse("3.1415 input"); }
#endif #endif
bool small() { bool small() {
double result = -1; double result = -1;
std::string str = "3e-1000"; std::string str = "3e-1000";
auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result); auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result);
if(r.ec != std::errc::result_out_of_range) { return false; } if (r.ec != std::errc::result_out_of_range) {
if(r.ptr != str.data() + 7) { return false; } return false;
if(result != 0) { return false; } }
if (r.ptr != str.data() + 7) {
return false;
}
if (result != 0) {
return false;
}
printf("small values go to zero\n"); printf("small values go to zero\n");
return true; return true;
} }
bool large() { bool large() {
double result = -1; double result = -1;
std::string str = "3e1000"; std::string str = "3e1000";
auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result); auto r = fast_float::from_chars(str.data(), str.data() + str.size(), result);
if(r.ec != std::errc::result_out_of_range) { return false; } if (r.ec != std::errc::result_out_of_range) {
if(r.ptr != str.data() + 6) { return false; } return false;
if(result != std::numeric_limits<double>::infinity()) { return false; } }
if (r.ptr != str.data() + 6) {
return false;
}
if (result != std::numeric_limits<double>::infinity()) {
return false;
}
printf("large values go to infinity\n"); printf("large values go to infinity\n");
return true; return true;
} }
int main() { int main() {