I am making an http get call from an Angular client to a web api .net Framework 4.7
I have a service that returns me an object with values, including a property of type "long", the issue is that when I debug the response in the api, it returns a number 9997773333333335 (which is what I expect) but when I get to browser translates it to 9997773333333336
In summary:
long data type, in the database it remains as 9997773333333335 but when receiving the response in the front it arrives as 9997773333333336.
Can someone explain to me why this happens? are you doing a rounding? How could I avoid it?
Fact: the field in the DB is a Bigint.
backend response:
Frontend result:
The problem is that the numbers you are using are larger than Number.MAX_SAFE_INTEGER. JavaScript can't accurately represent integers this large using the Number type, so errors like what you are seeing are to be expected.
Try passing these values to the front-end as strings rather than longs. If you need to do any calculation with them client-side, convert these strings to BigInts first.