From 31e5271921bf645facc7937a71e34aac484a0cc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Sun, 22 Feb 2015 07:44:40 +0100 Subject: [PATCH] Fixed number formating issue when InfluxDB return MAX float64, Fixes #1402 --- src/app/components/kbn.js | 4 ++++ src/test/specs/kbn-format-specs.js | 1 + 2 files changed, 5 insertions(+) diff --git a/src/app/components/kbn.js b/src/app/components/kbn.js index 6d3c1e2096e..398fede6350 100644 --- a/src/app/components/kbn.js +++ b/src/app/components/kbn.js @@ -326,11 +326,15 @@ function($, _, moment) { } var steps = 0; + var limit = extArray.length; while (Math.abs(size) >= factor) { steps++; size /= factor; + + if (steps >= limit) { return "NA"; } } + if (steps > 0) { decimals = scaledDecimals + (3 * steps); } diff --git a/src/test/specs/kbn-format-specs.js b/src/test/specs/kbn-format-specs.js index 726ef567327..ecc294d0543 100644 --- a/src/test/specs/kbn-format-specs.js +++ b/src/test/specs/kbn-format-specs.js @@ -25,6 +25,7 @@ define([ describeValueFormat('none', 2.75e-10, 0, 10, '3e-10'); describeValueFormat('none', 0, 0, 2, '0'); + describeValueFormat('bytes', -1.57e+308, -1.57e+308, 2, 'NA'); describeValueFormat('ns', 25, 1, 0, '25 ns'); describeValueFormat('ns', 2558, 50, 0, '2.56 µs');