aboutsummaryrefslogtreecommitdiffstats
path: root/util/stream/format.cpp
diff options
context:
space:
mode:
authorMikhail Borisov <borisov.mikhail@gmail.com>2022-02-10 16:45:39 +0300
committerDaniil Cherednik <dcherednik@yandex-team.ru>2022-02-10 16:45:39 +0300
commita6a92afe03e02795227d2641b49819b687f088f8 (patch)
treef6984a1d27d5a7ec88a6fdd6e20cd5b7693b6ece /util/stream/format.cpp
parentc6dc8b8bd530985bc4cce0137e9a5de32f1087cb (diff)
downloadydb-a6a92afe03e02795227d2641b49819b687f088f8.tar.gz
Restoring authorship annotation for Mikhail Borisov <borisov.mikhail@gmail.com>. Commit 1 of 2.
Diffstat (limited to 'util/stream/format.cpp')
-rw-r--r--util/stream/format.cpp50
1 files changed, 25 insertions, 25 deletions
diff --git a/util/stream/format.cpp b/util/stream/format.cpp
index 3996130df5..b4ffa0aac1 100644
--- a/util/stream/format.cpp
+++ b/util/stream/format.cpp
@@ -1,7 +1,7 @@
#include "format.h"
#include "output.h"
-#include <util/generic/ymath.h>
+#include <util/generic/ymath.h>
#include <util/string/cast.h>
namespace NFormatPrivate {
@@ -12,27 +12,27 @@ namespace NFormatPrivate {
}
static inline IOutputStream& PrintDoubleShortly(IOutputStream& os, const double& d) {
- // General case: request 3 significant digits
- // Side-effect: allows exponential representation
- EFloatToStringMode mode = PREC_NDIGITS;
- int ndigits = 3;
-
- if (IsValidFloat(d) && Abs(d) < 1e12) {
- // For reasonably-sized finite values, it's better to avoid
- // exponential representation.
- // Use compact fixed representation and determine
- // precision based on magnitude.
- mode = PREC_POINT_DIGITS_STRIP_ZEROES;
- if (i64(Abs(d) * 100) < 1000) {
- ndigits = 2;
- } else if (i64(Abs(d) * 10) < 1000) {
- ndigits = 1;
- } else {
- ndigits = 0;
- }
- }
-
- return os << Prec(d, mode, ndigits);
+ // General case: request 3 significant digits
+ // Side-effect: allows exponential representation
+ EFloatToStringMode mode = PREC_NDIGITS;
+ int ndigits = 3;
+
+ if (IsValidFloat(d) && Abs(d) < 1e12) {
+ // For reasonably-sized finite values, it's better to avoid
+ // exponential representation.
+ // Use compact fixed representation and determine
+ // precision based on magnitude.
+ mode = PREC_POINT_DIGITS_STRIP_ZEROES;
+ if (i64(Abs(d) * 100) < 1000) {
+ ndigits = 2;
+ } else if (i64(Abs(d) * 10) < 1000) {
+ ndigits = 1;
+ } else {
+ ndigits = 0;
+ }
+ }
+
+ return os << Prec(d, mode, ndigits);
}
}
@@ -51,11 +51,11 @@ void Out<NFormatPrivate::THumanReadableSize>(IOutputStream& stream, const NForma
if (v < base) {
NFormatPrivate::PrintDoubleShortly(stream, v);
- } else if (v < base2) {
+ } else if (v < base2) {
NFormatPrivate::PrintDoubleShortly(stream, v / (double)base) << 'K';
- } else if (v < base3) {
+ } else if (v < base3) {
NFormatPrivate::PrintDoubleShortly(stream, v / (double)base2) << 'M';
- } else if (v < base4) {
+ } else if (v < base4) {
NFormatPrivate::PrintDoubleShortly(stream, v / (double)base3) << 'G';
} else {
NFormatPrivate::PrintDoubleShortly(stream, v / (double)base4) << 'T';