From: Mykola Golub Date: Thu, 15 Jan 2015 14:59:23 +0000 (+0200) Subject: Add a type (weightf_t) to output float weights. X-Git-Tag: v0.93~227^2~13 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=b42c7e28f0ead543db3b503b02bfc22a0b42ab9c;p=ceph.git Add a type (weightf_t) to output float weights. Signed-off-by: Mykola Golub --- diff --git a/src/include/types.h b/src/include/types.h index 949da5788e4..7c10b1e38e3 100644 --- a/src/include/types.h +++ b/src/include/types.h @@ -452,6 +452,23 @@ inline ostream& operator<<(ostream &oss, health_status_t status) { } #endif +struct weightf_t { + float v; + weightf_t(float _v) : v(_v) {} +}; + +inline ostream& operator<<(ostream& out, const weightf_t& w) +{ + if (w.v < -0.01) { + return out << "-"; + } else if (w.v < 0.000001) { + return out << "0"; + } else { + std::streamsize p = out.precision(); + return out << std::fixed << std::setprecision(5) << w.v << std::setprecision(p); + } +} + struct shard_id_t { uint8_t id;