<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: C#, decimal.toString(), and how to get rid of trailing zeros</title>
	<atom:link href="http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/feed/" rel="self" type="application/rss+xml" />
	<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/</link>
	<description>The blog for developers</description>
	<lastBuildDate>Wed, 11 Apr 2012 20:31:39 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0</generator>
	<item>
		<title>By: 2011 in review &#124; Blinded by the lights</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-220948</link>
		<dc:creator>2011 in review &#124; Blinded by the lights</dc:creator>
		<pubDate>Wed, 25 Jan 2012 21:20:27 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-220948</guid>
		<description>[...] popular post: C#, decimal.toString(), and how to get rid of trailing zeros &#8211; 17,302 [...]</description>
		<content:encoded><![CDATA[<p>[...] popular post: C#, decimal.toString(), and how to get rid of trailing zeros &#8211; 17,302 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: rkh</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-219476</link>
		<dc:creator>rkh</dc:creator>
		<pubDate>Sat, 21 Jan 2012 18:01:14 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-219476</guid>
		<description>thanks so much</description>
		<content:encoded><![CDATA[<p>thanks so much</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ??????? &#187; Blog Archive &#187; C#, decimal.toString(), and how to get rid of trailing zeros</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-157495</link>
		<dc:creator>??????? &#187; Blog Archive &#187; C#, decimal.toString(), and how to get rid of trailing zeros</dc:creator>
		<pubDate>Fri, 26 Aug 2011 13:16:00 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-157495</guid>
		<description>[...] In the application I already had NumberFormatInfo for displaying monetary values and percentages. An object of that type was defined as follows:   view plaincopy to clipboardprint? [...]</description>
		<content:encoded><![CDATA[<p>[...] In the application I already had NumberFormatInfo for displaying monetary values and percentages. An object of that type was defined as follows:   view plaincopy to clipboardprint? [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Paolo</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-95864</link>
		<dc:creator>Paolo</dc:creator>
		<pubDate>Wed, 16 Mar 2011 10:34:16 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-95864</guid>
		<description>Yes, Microsoft documentation is well hidden:
http://msdn.microsoft.com/en-us/library/0c899ak8%28v=VS.90%29.aspx
Nice tutorial.</description>
		<content:encoded><![CDATA[<p>Yes, Microsoft documentation is well hidden:<br />
<a href="http://msdn.microsoft.com/en-us/library/0c899ak8%28v=VS.90%29.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/0c899ak8%28v=VS.90%29.aspx</a><br />
Nice tutorial.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: xxx</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-33763</link>
		<dc:creator>xxx</dc:creator>
		<pubDate>Wed, 21 Apr 2010 10:34:30 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-33763</guid>
		<description>Got the same problem today :)!

There is a hack with double.

decimal d1 = 0.0230000m;
MessageBox.Show(((double)d1).ToString());</description>
		<content:encoded><![CDATA[<p>Got the same problem today <img src='http://dobrzanski.net/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> !</p>
<p>There is a hack with double.</p>
<p>decimal d1 = 0.0230000m;<br />
MessageBox.Show(((double)d1).ToString());</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Maik Wiege</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-22032</link>
		<dc:creator>Maik Wiege</dc:creator>
		<pubDate>Fri, 04 Sep 2009 09:19:59 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-22032</guid>
		<description>You should use 

value.ToString(&quot;G29&quot;);

this makes exactly what you want. It uses the most compact representation of the Decimal value by removing all trailing zeros, no matter how many non-zero values are in front of them.
Check the explanation of the G (General) specifier for numeric formating at the docs.</description>
		<content:encoded><![CDATA[<p>You should use </p>
<p>value.ToString(&#8220;G29&#8243;);</p>
<p>this makes exactly what you want. It uses the most compact representation of the Decimal value by removing all trailing zeros, no matter how many non-zero values are in front of them.<br />
Check the explanation of the G (General) specifier for numeric formating at the docs.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jarosław Dobrzański</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-21142</link>
		<dc:creator>Jarosław Dobrzański</dc:creator>
		<pubDate>Thu, 13 Aug 2009 08:29:13 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-21142</guid>
		<description>I believe my suggestion is safer. Thanks for the tip anyway!</description>
		<content:encoded><![CDATA[<p>I believe my suggestion is safer. Thanks for the tip anyway!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tewux</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-21137</link>
		<dc:creator>tewux</dc:creator>
		<pubDate>Thu, 13 Aug 2009 07:08:35 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-21137</guid>
		<description>Maybe it&#039;s not better, but works:
public static string ToTrimmedString(this decimal value)
{
	return value.ToString().TrimEnd(&#039;0&#039;, CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]);
}</description>
		<content:encoded><![CDATA[<p>Maybe it&#8217;s not better, but works:<br />
public static string ToTrimmedString(this decimal value)<br />
{<br />
	return value.ToString().TrimEnd(&#8217;0&#8242;, CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator[0]);<br />
}</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Olivier de Rivoyre</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-19085</link>
		<dc:creator>Olivier de Rivoyre</dc:creator>
		<pubDate>Tue, 09 Jun 2009 12:58:35 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-19085</guid>
		<description>Thanks for this. Now I use this to have a &#039;human&#039; display (do not display the trailing zeros):

decimal d = 12.103000m;
Console.WriteLine(d.ToString(&quot;#.################################&quot;, CultureInfo.InvariantCulture));
///Ouput: 12.103

Anyne have a better solution?</description>
		<content:encoded><![CDATA[<p>Thanks for this. Now I use this to have a &#8216;human&#8217; display (do not display the trailing zeros):</p>
<p>decimal d = 12.103000m;<br />
Console.WriteLine(d.ToString(&#8220;#.################################&#8221;, CultureInfo.InvariantCulture));<br />
///Ouput: 12.103</p>
<p>Anyne have a better solution?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: osten</title>
		<link>http://dobrzanski.net/2009/05/14/c-decimaltostring-and-how-to-get-rid-of-trailing-zeros/comment-page-1/#comment-19056</link>
		<dc:creator>osten</dc:creator>
		<pubDate>Mon, 08 Jun 2009 13:53:14 +0000</pubDate>
		<guid isPermaLink="false">http://dobrzanski.net/?p=324#comment-19056</guid>
		<description>Hey!

Thanks for this, finding good documentation from microsoft about formatting is a pain. Also this does not work for all datatypes, just decimal (and probably float etc), anyway, thanks again.</description>
		<content:encoded><![CDATA[<p>Hey!</p>
<p>Thanks for this, finding good documentation from microsoft about formatting is a pain. Also this does not work for all datatypes, just decimal (and probably float etc), anyway, thanks again.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

