INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

#### Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
• Talk With Other Members
• Be Notified Of Responses
To Your Posts
• Keyword Search
• One-Click Access To Your
Favorite Forums
• Automated Signatures
On Your Posts
• Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

#### Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

# formatting decimals

 Forum Search FAQs Links MVPs

## formatting decimals

(OP)
Hello,

I'm trying to wrap my head around formatting decimals.

I have a specification that needs to be met, and it's outlined as follows:

#### Quote:

For decimals between +/-0.0000001 and +/-100000: Optional ‘-‘ character, followed by 5 significant digits before the decimal, a ‘.’ character, followed by 6 significant digits after the decimal. If less than 5 significant digits before the decimal, pad with spaces; the optional ‘-‘ character will be right justified. If less than 6 significant digits after the decimal, pad with zeros.

For decimals below -100000 or above 100000: Optional ‘-‘ character, followed by “0.” and 6 significant digits, followed by ‘E’, followed by ‘-‘ or ‘+’, followed by a 2 digit exponent. If the value has less than 6 significant digits, pad with zeros. If the exponent has less than 2 significant digits, pad with zeros.

For 0.0m: "_____0.000000" (<-- where _ means space)

I've read the following MSDN articles:

http://msdn.microsoft.com/en-us/library/dwhawy9k(v...
http://msdn.microsoft.com/en-us/library/dwhawy9k(v...

...and they've helped me wrap my head around some rather simple cases, but the one above is quite complex and I'm getting very confused (especially with the whitespace padding--is that even possible?). Can anyone help me construct a format string that will meet the above specifications?

#### Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

#### Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

### Reply To This Thread

#### Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

# Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

• Talk To Other Members
• Notification Of Responses To Questions
• Favorite Forums One Click Access
• Keyword Search Of All Posts, And More...

Register now while it's still free!

Already a member? Close this window and log in.