mirror of
https://github.com/fastfloat/fast_float.git
synced 2025-12-06 08:46:49 +08:00
formatting
This commit is contained in:
parent
c8abf94560
commit
9117ec4f69
@ -78,25 +78,37 @@ constexpr double constexptest() { return parse("3.1415 input"); }
|
||||
#endif
|
||||
|
||||
bool small() {
|
||||
double result = -1;
|
||||
std::string str = "3e-1000";
|
||||
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.ptr != str.data() + 7) { return false; }
|
||||
if(result != 0) { return false; }
|
||||
double result = -1;
|
||||
std::string str = "3e-1000";
|
||||
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.ptr != str.data() + 7) {
|
||||
return false;
|
||||
}
|
||||
if (result != 0) {
|
||||
return false;
|
||||
}
|
||||
printf("small values go to zero\n");
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool large() {
|
||||
double result = -1;
|
||||
std::string str = "3e1000";
|
||||
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.ptr != str.data() + 6) { return false; }
|
||||
if(result != std::numeric_limits<double>::infinity()) { return false; }
|
||||
double result = -1;
|
||||
std::string str = "3e1000";
|
||||
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.ptr != str.data() + 6) {
|
||||
return false;
|
||||
}
|
||||
if (result != std::numeric_limits<double>::infinity()) {
|
||||
return false;
|
||||
}
|
||||
printf("large values go to infinity\n");
|
||||
return true;
|
||||
return true;
|
||||
}
|
||||
|
||||
int main() {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user