<?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: Negative Rounding in VBA</title>
	<atom:link href="http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Thu, 09 Feb 2012 23:42:03 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Nils</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-38182</link>
		<dc:creator>Nils</dc:creator>
		<pubDate>Wed, 25 Feb 2009 19:24:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-38182</guid>
		<description>&lt;p&gt;Hi!&lt;/p&gt;
&lt;p&gt;I been using this code snippet for random numbers or a slightly changed one. One solution is to randomly set the number to a negative one or a positive one and the problem with getting negative random numbers is solved! Thanks for a interesting site!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;http://vbaexcel.eu/vba-macro-code/rnd-random-function&quot; rel=&quot;nofollow&quot;&gt;http://vbaexcel.eu/vba-macro-code/rnd-random-function&lt;/a&gt;&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi!</p>
<p>I been using this code snippet for random numbers or a slightly changed one. One solution is to randomly set the number to a negative one or a positive one and the problem with getting negative random numbers is solved! Thanks for a interesting site!</p>
<p><a href="http://vbaexcel.eu/vba-macro-code/rnd-random-function" rel="nofollow">http://vbaexcel.eu/vba-macro-code/rnd-random-function</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DaveB</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-37733</link>
		<dc:creator>DaveB</dc:creator>
		<pubDate>Wed, 04 Feb 2009 14:04:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-37733</guid>
		<description>&lt;p&gt;Harald&#039;s formula is the one I tend to use but be aware it needs ammending if you are rounding negative numbers (instead of adding 0.5 you need to subtract it)&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Harald&#8217;s formula is the one I tend to use but be aware it needs ammending if you are rounding negative numbers (instead of adding 0.5 you need to subtract it)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ross</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-12451</link>
		<dc:creator>ross</dc:creator>
		<pubDate>Sun, 22 May 2005 11:59:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-12451</guid>
		<description>&lt;p&gt;rounding! so many issues with roundng, there is a good few artiles on MSDN about it, VB and employ diffrent rounding methods, so just be careful!&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>rounding! so many issues with roundng, there is a good few artiles on MSDN about it, VB and employ diffrent rounding methods, so just be careful!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald Staff</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-12448</link>
		<dc:creator>Harald Staff</dc:creator>
		<pubDate>Sat, 21 May 2005 21:29:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-12448</guid>
		<description>&lt;p&gt;Hi AmonRa&lt;/p&gt;
&lt;p&gt;My function introduces nada, it it a ROUND replacement. What you talk about is known as &quot;bankers rounding&quot; and if we want bankers rounding and think that ROUND stinks then we write a function that does bankers rounding instead of the stupid ROUND things. Like&lt;/p&gt;
&lt;p&gt;Function VBRound(D As Double, L As Long) As Double&lt;br&gt;
Dim x As Double&lt;br&gt;
x = 10 ^ L&lt;br&gt;
VBRound = CLng(D * x) / x&lt;br&gt;
End Function&lt;/p&gt;
&lt;p&gt;Best wishes Harald&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Hi AmonRa</p>
<p>My function introduces nada, it it a ROUND replacement. What you talk about is known as &#8220;bankers rounding&#8221; and if we want bankers rounding and think that ROUND stinks then we write a function that does bankers rounding instead of the stupid ROUND things. Like</p>
<p>Function VBRound(D As Double, L As Long) As Double<br />
Dim x As Double<br />
x = 10 ^ L<br />
VBRound = CLng(D * x) / x<br />
End Function</p>
<p>Best wishes Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: AmonRa</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-12442</link>
		<dc:creator>AmonRa</dc:creator>
		<pubDate>Fri, 20 May 2005 20:09:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-12442</guid>
		<description>&lt;p&gt;If it only was that easy&lt;/p&gt;
&lt;p&gt;Harald&#039;s function introduces a 6% upward bias&lt;/p&gt;
&lt;p&gt;We have 10 digits of which 0 doesn&#039;t need rounding&lt;br&gt;
That leaves 9 digits which introduce an error when rounded.&lt;br&gt;
1 to 4 we round down&lt;br&gt;
6 to 9 we round up&lt;br&gt;
5 we have to assign a 50/50 chance to either up or down.&lt;/p&gt;
&lt;p&gt;Assuming a uniform distribution of digits we can look at the digit before the 5 and round up when this is an even digit or round down when this is an odd digit.&lt;/p&gt;
&lt;p&gt;Yes, I am aware that most of us remember rounding up from 5 from school math, but it introduces an upward bias (assuming uniformly distributed digits)&lt;/p&gt;
&lt;p&gt;Real life data may show different distributions of digits, leading the interesting discussions about pricing practices in supermarkets when at the till there will be a rounding to multiples of 5 cents.&lt;br&gt;
Of course there isn;t a problem in this case when we assume unifrom distributions.&lt;/p&gt;
&lt;p&gt;Cheers&lt;/p&gt;
&lt;p&gt;And thanks for this blog Dick&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>If it only was that easy</p>
<p>Harald&#8217;s function introduces a 6% upward bias</p>
<p>We have 10 digits of which 0 doesn&#8217;t need rounding<br />
That leaves 9 digits which introduce an error when rounded.<br />
1 to 4 we round down<br />
6 to 9 we round up<br />
5 we have to assign a 50/50 chance to either up or down.</p>
<p>Assuming a uniform distribution of digits we can look at the digit before the 5 and round up when this is an even digit or round down when this is an odd digit.</p>
<p>Yes, I am aware that most of us remember rounding up from 5 from school math, but it introduces an upward bias (assuming uniformly distributed digits)</p>
<p>Real life data may show different distributions of digits, leading the interesting discussions about pricing practices in supermarkets when at the till there will be a rounding to multiples of 5 cents.<br />
Of course there isn;t a problem in this case when we assume unifrom distributions.</p>
<p>Cheers</p>
<p>And thanks for this blog Dick</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Harald Staff</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-12439</link>
		<dc:creator>Harald Staff</dc:creator>
		<pubDate>Fri, 20 May 2005 08:31:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-12439</guid>
		<description>&lt;p&gt;I like functions for those things.&lt;/p&gt;
&lt;p&gt;Function VBRound(D As Double, L As Long) As Double&lt;br&gt;
Dim x As Double&lt;br&gt;
x = 10 ^ L&lt;br&gt;
VBRound = Int(D * x + 0.5) / x&lt;br&gt;
End Function&lt;/p&gt;
&lt;p&gt;Best wishes Harald&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>I like functions for those things.</p>
<p>Function VBRound(D As Double, L As Long) As Double<br />
Dim x As Double<br />
x = 10 ^ L<br />
VBRound = Int(D * x + 0.5) / x<br />
End Function</p>
<p>Best wishes Harald</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chip</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-12438</link>
		<dc:creator>Chip</dc:creator>
		<pubDate>Fri, 20 May 2005 06:52:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-12438</guid>
		<description>&lt;p&gt;Another option I&#039;ve used that does actual rounding, not truncation:&lt;/p&gt;
&lt;p&gt;round((56662/1000),3)*1000&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Another option I&#8217;ve used that does actual rounding, not truncation:</p>
<p>round((56662/1000),3)*1000</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dick Kusleika</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-12437</link>
		<dc:creator>Dick Kusleika</dc:creator>
		<pubDate>Fri, 20 May 2005 01:14:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-12437</guid>
		<description>&lt;p&gt;Eric:  No, you&#039;re not mistaken.  I&#039;m using the term rounding rather carelessly here.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Eric:  No, you&#8217;re not mistaken.  I&#8217;m using the term rounding rather carelessly here.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Eric W. Bachtal</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-12435</link>
		<dc:creator>Eric W. Bachtal</dc:creator>
		<pubDate>Thu, 19 May 2005 23:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-12435</guid>
		<description>&lt;p&gt;Unless I&#039;m mistaken, I don&#039;t believe your integer division is rounding - it&#039;s truncating.  So, when given 56652 is will return $56,000, not $57,000.&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>Unless I&#8217;m mistaken, I don&#8217;t believe your integer division is rounding &#8211; it&#8217;s truncating.  So, when given 56652 is will return $56,000, not $57,000.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rob van Gelder</title>
		<link>http://www.dailydoseofexcel.com/archives/2005/05/19/negative-rounding-in-vba/#comment-12434</link>
		<dc:creator>Rob van Gelder</dc:creator>
		<pubDate>Thu, 19 May 2005 23:27:00 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=1136#comment-12434</guid>
		<description>&lt;p&gt;more rounding:&lt;br&gt;
worksheetfunction.round(56652, -3)&lt;br&gt;
or&lt;br&gt;
56652 - 56652 mod 1000&lt;/p&gt;
</description>
		<content:encoded><![CDATA[<p>more rounding:<br />
worksheetfunction.round(56652, -3)<br />
or<br />
56652 &#8211; 56652 mod 1000</p>
]]></content:encoded>
	</item>
</channel>
</rss>

