Upper and lower capping for percentiles

  This is a work around to hide the loss of statistical accuracy due to
  data binning in histograms. For cases where a percentile value is lower
  than the minimum or greater than maximum read values percentile is capped
  to minimum\maximum value accordingly.

  Fixed the message printed by "PrintConfidenceIntervals(double)", instead
  of printing 0.99% it now prints 99%.

  Added more test cases to cover corner cases for clipping.

Change-Id: Ifae41336282a4dfdbeb325b2c2b87c41c8030c38
diff --git a/src/base/histogram-inl.h b/src/base/histogram-inl.h
index 3ffb9a0..9e3de9f 100644
--- a/src/base/histogram-inl.h
+++ b/src/base/histogram-inl.h
@@ -169,7 +169,7 @@
   double per_1 = per_0 + interval;
   os << Name() << ":\t";
   TimeUnit unit = GetAppropriateTimeUnit(Mean() * kAdjust);
-  os << interval << "% C.I. "
+  os << (interval * 100) << "% C.I. "
      << FormatDuration(Percentile(per_0) * kAdjust, unit);
   os << "-" << FormatDuration(Percentile(per_1) * kAdjust, unit) << " ";
   os << "Avg: " << FormatDuration(Mean() * kAdjust, unit) << " Max: ";
@@ -240,6 +240,13 @@
 
   double value = lower_value + (upper_value - lower_value) *
                                (per - lower_perc) / (upper_perc - lower_perc);
+
+  if (value < min_value_added_) {
+    value = min_value_added_;
+  } else if (value > max_value_added_) {
+    value = max_value_added_;
+  }
+
   return value;
 }