Skip to main content

BigDecimal from json loses precision

The network call shows that the backend is sending this:

"uom" : "EA",
"qty" : 1.123456789012345678

but when it reaches the frontend, using console.log:

{ 
  qty: 1.1234567890123457, 
  uom: "EA"
}

why is the javascript losing the last digit or truncating the number?

The number is represented using a BigDecimal in java. The frontend use AngularJs framework, makes a GET call to the backend requesting a JSON.

Via Active questions tagged javascript - Stack Overflow https://ift.tt/bhJWfBg

Comments