0

DataTables is changing my values (and I believe my data types thus breaking sorting).

My currency/ints on other cols are not sorting properly, but 1 col (ints) is being sorted (even though a very similar col next to it doesn't).

I've tried Advanced initialisation and added data-order="NUMBER HERE" but even then it still isn't sorting correctly.

I've wasted hours and hours looking/trying various solutions so am hoping the great community of stackoverflow can help.

Edit: One very odd thing is I am giving it a (double) 1.89 and it is displaying the value 1.8900000000000001, all other numbers are displayed correcly, just 1.89 which is doing this, in my DB this is stored as double(10,2) - resolved using decimal(8,2)

LeeJ
  • 137
  • 1
  • 12
  • 1
    I think you may need to read up on IEEE Floating Pont numbers and the issues they have with certain numbers https://en.wikipedia.org/wiki/Floating_point – RiggsFolly Jan 06 '17 at 12:53
  • 1
    [Why Are Floating Point Numbers Inaccurate?](http://stackoverflow.com/questions/21895756/why-are-floating-point-numbers-inaccurate) and [What Every Computer Scientist Should Know About Floating-Point Arithmetic](https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html) – sidyll Jan 06 '17 at 12:54
  • Default to 10,2, where 2 is the number of decimals and 10 is the total number of digits (including decimals). Decimal precision can go to 24 places for a FLOAT – manny Jan 06 '17 at 12:54
  • Also read these (and c'mon, learn to search) [Use Float or Decimal for Accounting Application Dollar Amount?](http://stackoverflow.com/questions/61872/use-float-or-decimal-for-accounting-application-dollar-amount) and [Best data type to store money values in MySQL](http://stackoverflow.com/questions/13030368/best-data-type-to-store-money-values-in-mysql) – sidyll Jan 06 '17 at 12:57

0 Answers0