Formatting currency within a specific precision range
- by Alex Prose
I am trying to format currency that will always contain 2 decimal digits, but if there are extra digits of accuracy to display up to five. As an example:
for value = 5.0
display: $5.00
for value = 5.023
display: $5.023
for value = 5.333333333333333
display: $5.33333
I have been playing with the .ToString() formatting, but I can't seem to find the right match of options.
Clarification:
I want to show from 2-5 decimals, truncating zeros after the second digit.
for value = 5.000000000000000
display: $5.00
for value = 5.333333333333333
display: $5.33333