I am making an ajax call to a web service and fetching JSON data which contains decimal properties.
Issue:
When I see values on the server-side before returning and browser network tab response for the request both have the value which does not match with inspecting of the success callback of jQuery ajax call.
Differences:
Original Value : 5.74999999999999999999999999
Ajax success callback: 5.75
Original Value : 465.90909090909090909090909088
Ajax success callback: 465.90909090909093
Note: I am not doing any calculations in javascript. Just trying to display.
I tried to parse JSON using JSON.parse which will parse correctly. I think there is some issue with the jQuery library itself where JSON response is converted javascript object. Is there any way to correct this behavior.
Additional Info:
An experiment not exactly relevant to the question because the calculation is not being done in the javascript side.
Interestingly value is not correct in Windows Calculator, Google Search, Browser console.
(37.272727272727272727272727270 *522.5)/100 = 194.75 instead of 4.7499999999999999999999
Any clarifications on this would be appreciated.
With regards, Nithin B.