Solved

Trimming a number to 2 decimal places + remove trailing zeros

Posted on 2006-11-10
2
948 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

Question has a verified solution.

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

Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my asp.net applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on 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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.

623 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