Solved

Trimming a number to 2 decimal places + remove trailing zeros

Posted on 2006-11-10
2
946 Views
Last Modified: 2007-12-19
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
Comment
Question by:Rouchie
2 Comments
 
LVL 43

Accepted Solution

by:
TimCottee earned 500 total points
ID: 17913648
Hi Rouchie,

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

Tim Cottee
0
 
LVL 25

Author Comment

by:Rouchie
ID: 17913877
I knew it would be really simple but couldn't find any information online to help me solve it!

Thanks Tim.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question