datatables 3: Number format gives wrong output for negative numbers

datatables 3: Number format gives wrong output for negative numbers

Björn PedersenBjörn Pedersen Posts: 3Questions: 1Answers: 0

Link to test case:
Error messages shown:
Description of problem:

The determiniation of the decimal part fails for negative numbers:

See this debug output with values displayed:

          return null == a && (a = ht),
            null == i && (i = gt),
            {
                display: function(e) {e = -1140516
                    var t, r, n;t = "-", r = 1140516.46, n = ",81032.46"
                    return "number" != typeof e && "string" != typeof e || "" === e || null === e ? e : (t = (n = "number" == typeof e ? e : parseFloat(e)) < 0 ? "-" : "",e = -1140516
                    1e11 <= (r = Math.abs(n)) || r < 1e-4 && 0 !== r ? (r = n.toExponential(o).split(/e\+?/))[0] + " x 10<sup>" + r[1] + "</sup>" : isNaN(n) ? k.escapeHtml(e) : (n = n.toFixed(o),r = 1140516.46
                    r = Math.abs(n),
                    e = parseInt(n, 10),e = -1140516
                    n = o ? i + (r - e).toFixed(o).substring(2) : "",r = 1140516.46
                    (t = 0 === e && 0 === parseFloat(n) ? "" : t) + (l || "") + e.toString().replace(/\B(?=(\d{3})+(?!\d))/g, a) + n + (s || "")))
                }
            }
        },

r is always positive, but the integer val e is negative for negative numbers, so r-e gives a large sum instedd of the decimal part.

Answers

Sign In or Register to comment.