Yeah, nice one. I thought about that but I didn't have a use case for it yet myself. I'm not sure if toFixed()
is the right solution though, as "officially" the simplified rep should be floored, not rounded.
You are viewing a single comment's thread from:
hmmm... it should be conditional then.
Yeah, or something like this:
function toPrecision(value, precision) { const multiplier = Math.pow(10, precision); return Math.floor(value * multiplier) / multiplier; }