Skip to content

Instantly share code, notes, and snippets.

@deepakdargade
Forked from tomraithel/gist:3803731
Last active August 29, 2015 14:23
Show Gist options
  • Save deepakdargade/acd815d9578c376acfd0 to your computer and use it in GitHub Desktop.
Save deepakdargade/acd815d9578c376acfd0 to your computer and use it in GitHub Desktop.
"%g" % ("%0.2f" % 16.4555)
@deepakdargade
Copy link
Author

rails: strip insignificant zeros

= number_with_precision(3.50, strip_insignificant_zeros: true, precision: 2)
3.5

= number_with_precision(3.0, strip_insignificant_zeros: true, precision: 2)
3

= number_with_precision(4.02, strip_insignificant_zeros: true, precision: 2)
4.02

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment