]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
Add a type (weightf_t) to output float weights.
authorMykola Golub <mgolub@mirantis.com>
Thu, 15 Jan 2015 14:59:23 +0000 (16:59 +0200)
committerSage Weil <sage@redhat.com>
Sat, 17 Jan 2015 16:57:26 +0000 (08:57 -0800)
Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/include/types.h

index 949da5788e438f2680f19ab318f9e52997c8a677..7c10b1e38e39a85b0e99328ebce87c5c66b17379 100644 (file)
@@ -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;