2
newjsonData.sort(function(a, b) {
  return (a.Id - b.Id)
});
oldjsonData.sort(function(a, b) {
  return (a.Id - b.Id)
})

In above function I am sorting the json value based on ID and one of the node contains float value which is getting round off.

I am getting this 1.1103391379964032864981076624 value from response and it is getting round off to this 1.1103392. I don't want round off value I required the original one

jmargolisvt
  • 5,722
  • 4
  • 29
  • 46
benevolent
  • 101
  • 1
  • 5
  • 1
    Does this answer your question? [How to deal with floating point number precision in JavaScript?](https://stackoverflow.com/questions/1458633/how-to-deal-with-floating-point-number-precision-in-javascript) – jmargolisvt Aug 19 '21 at 16:03
  • Javascript can't handle large decimal places (or large integers) like that. – I wrestled a bear once. Aug 19 '21 at 16:04
  • Even if you presented a number of such precision as an integer, you would still lose precision in javascript's number type. It just doesn't have enough bits. You might have luck treating your numbers as strings, padding with leading zeros such that the decimal point always appears in the same position and sorting lexicographically instead... – spender Aug 19 '21 at 16:12

0 Answers0