Solved

DataFormatString: how to include padding zeros?

Posted on 2004-04-13
2
1,955 Views
Last Modified: 2012-05-04
Hi,

which (c#) dataformat string would you choose:

input: 1523.460
current output: 1523.46

Desired output: 1523.460
0
Comment
Question by:Raab314159
2 Comments
 

Author Comment

by:Raab314159
ID: 10812584
REM:

The number is not allowed to have a fixed number of digits! Sometimes, the number may represent temperature, sometimes wavelenght, etc
0
 
LVL 10

Accepted Solution

by:
ptmcomp earned 125 total points
ID: 10813478
If you want the input to be equal to the output use string or save the number of significant digits in a seperate variable.

To format a number with 3 digits after decimal point use: string.Format("{0:#.000}", 1523.46)

In a float / double / decimal there is no information about the number of significant digits. You have to implement it yourself or you might find a 3rd party library which provides this functionality.
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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