You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Calling roundTo(103.35, 0.1) gives 103.30000000000001 where it should give 103.4.
Original function:
/** Round a number `n` to the nearest multiple of `increment`. */
export function roundTo(n: number, increment = 1) {
return Math.round(n / increment) * increment;
}
I'm not sure if it is worth adding this performance overhead to deal with floating-point edge cases, but we'll definitely keep it in mind for future updates.
In this example, if you want to round to a certain number of decimal places, you could instead just use the round() function which should not have this issue:
Calling
roundTo(103.35, 0.1)
gives103.30000000000001
where it should give103.4
.Original function:
This function looks to work properly:
The text was updated successfully, but these errors were encountered: