471,348 Members | 1,325 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,348 software developers and data experts.

DataFormatString

Hi,

I have to display a double like this one 1.3234546 and this 2.0000.
If the double is like the first one then I only want to display 1.32.

This works with {0:F2}.

But with the second one I like to display 2. Not 2.00.

How can I do this?

Thanks!
Dec 6 '05 #1
1 3847
Well.... if you assing 2.0000000000 to a double, it will automatically
become 2, since there is no further precision required. you could solve
it with this:

Double dbl = 2.000000000000000000000;

if (dbl = Math.Floor(dbl))
{
return Convert.ToString(dbl) + ".00";
}

Dec 6 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by frank | last post: by
9 posts views Thread by Roy | last post: by
3 posts views Thread by Gerhard Pretorius | last post: by
1 post views Thread by Gerhard Pretorius | last post: by
1 post views Thread by Randall Parker | last post: by
1 post views Thread by Hardy Wang | last post: by
1 post views Thread by Ronak mishra | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.