Format infinity.
This commit is contained in:
@@ -141,7 +141,7 @@ int signbit(double value) {
|
||||
if (value < 0) return 1;
|
||||
if (value == value) return 0;
|
||||
int dec = 0, sign = 0;
|
||||
ecvt(value, 0, &dec, &sign);
|
||||
_ecvt(value, 0, &dec, &sign);
|
||||
return sign;
|
||||
}
|
||||
#endif
|
||||
@@ -337,6 +337,21 @@ void Formatter::FormatDouble(T value, const FormatSpec &spec, int precision) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (isinf(value)) {
|
||||
// Format infinity ourselves because sprintf's output is not consistent
|
||||
// across platforms.
|
||||
std::size_t size = 4;
|
||||
const char *inf = upper ? " INF" : " inf";
|
||||
if (!sign) {
|
||||
--size;
|
||||
++inf;
|
||||
}
|
||||
char *out = FormatString(inf, size, spec);
|
||||
if (sign)
|
||||
*out = sign;
|
||||
return;
|
||||
}
|
||||
|
||||
size_t offset = buffer_.size();
|
||||
unsigned width = spec.width;
|
||||
if (sign) {
|
||||
|
||||
Reference in New Issue
Block a user