0

I need to format decimal numbers (serializing them as a string) that have a different number of digits after the decimal place.

Basically I want to remove all trailing zeros after the decimal point, except always leaving at least 2 digits regardless of their numbers. So:

134.0000120 -> 134.000012
0.01000 -> 0.01
34.0000 -> 34.00
Etc.

What is the best approach to do this?

CorribView
  • 711
  • 1
  • 19
  • 44

0 Answers0