Closed yusufsahinhamza closed 3 years ago
The number of trailing zeros in the fraction part of the number is not stored when a Decimal is created, so it cannot be retrieved by a method call later.
Thanks for your suggestion but I don't want to make the extensive changes that would be required to support this.
Example workaround:
zeros = s => String(s).replace(/^.*[^0](?=0*$)/, "").length;
v = "987.65432100";
x = new Decimal(v)
x.z = zeros(v);
console.log(x.z); // 2
@MikeMcl Yes i also realized that after creating this issue but anyway your example workaround is good to use for me, you can close this issue if you wish, thank you!
It would be good to give an option to include zeros when using decimalPlaces function just like in the
precision .sd([include_zeros])
function.For example: