I have an Excel column containing part numbers. Here is a sample
As you can see, it can be many differ
For those using Rails, ActionView has the number_with_precision
method that takes a strip_insignificant_zeros: true
argument to handle this.
number_with_precision(13.00, precision: 2, strip_insignificant_zeros: true)
# => 13
number_with_precision(13.25, precision: 2, strip_insignificant_zeros: true)
# => 13.25
See the number_with_precision documentation for more information.