Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 954
  • Last Modified:

Trimming a number to 2 decimal places + remove trailing zeros

I'd like to display a numer in the format XXX.XX, but also trim off any trailing zeros that exist in the remaining 2 decimal places.

Can anyone tell me the best way to display this number?  I'm going to use the code in a function, that will accept a double value as the input.

i.e.
33.333333  --->  33.33
25.50         --->  25.5
50             --->   50
0
Rouchie
Asked:
Rouchie
1 Solution
 
TimCotteeCommented:
Hi Rouchie,

MyNumberString = MyNumericValue.ToString("#.##")

Tim Cottee
0
 
RouchieAuthor Commented:
I knew it would be really simple but couldn't find any information online to help me solve it!

Thanks Tim.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now