Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
fix(common): handle JS floating point errors in percent pipe #20329
What kind of change does this PR introduce?
What is the current behavior?
We multiply the number by 100 in the percent pipe which can lead to floating point errors with float numbers.
Issue Number: #20136
What is the new behavior?
We now shift the decimal separator without using math, which avoids the js floating point error.
Does this PR introduce a breaking change?
This is the only place where we change the number value (by a multiplication or something else that would trigger this js problem)
No, this is a fix because it removes an unexpected behavior that no one wants to get
Added more comments on the function
Updated the function to be less generic since we only use it here.
Added link to the source in the comments of the function
In packages/common/test/pipes/number_pipe_spec.ts, see the files changed by the commit
We have a bug report about this and I tend to agree with it. Do you really expect to get