1
0
mirror of https://github.com/DataTables/DataTables.git synced 2025-03-15 16:29:16 +01:00

Fix: number renderer displayed numbers incorrectly for negative numbers

This commit is contained in:
Allan Jardine 2014-06-18 14:24:30 +01:00
parent 4447b84c34
commit c38e140a52
2 changed files with 5 additions and 3 deletions

View File

@ -1 +1 @@
1fcedce42d4cb20dfa1e82e6bf7f9f871baac309 89ab148ad45a219c2623fcc75b15a59b7d0c7a2e

View File

@ -14139,13 +14139,15 @@
number: function ( thousands, decimal, precision, prefix ) { number: function ( thousands, decimal, precision, prefix ) {
return { return {
display: function ( d ) { display: function ( d ) {
d = parseFloat( d ); var negative = d < 0 ? '-' : '';
d = Math.abs( parseFloat( d ) );
var intPart = parseInt( d, 10 ); var intPart = parseInt( d, 10 );
var floatPart = precision ? var floatPart = precision ?
decimal+(d - intPart).toFixed( precision ).substring( 2 ): decimal+(d - intPart).toFixed( precision ).substring( 2 ):
''; '';
return (prefix||'') + return negative + (prefix||'') +
intPart.toString().replace( intPart.toString().replace(
/\B(?=(\d{3})+(?!\d))/g, thousands /\B(?=(\d{3})+(?!\d))/g, thousands
) + ) +