<?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: Minimum and maximum values of numeric data types</title>
	<atom:link href="http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/feed/" rel="self" type="application/rss+xml" />
	<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/</link>
	<description>Daily posts of Excel tips…and other stuff</description>
	<lastBuildDate>Wed, 15 May 2013 18:27:05 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: lhm</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-83039</link>
		<dc:creator>lhm</dc:creator>
		<pubDate>Mon, 18 Jun 2012 14:14:01 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-83039</guid>
		<description><![CDATA[Good point - as you say the longer number would either need to be entered as a string or else as the result of an expression.]]></description>
		<content:encoded><![CDATA[<p>Good point &#8211; as you say the longer number would either need to be entered as a string or else as the result of an expression.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Rothstein (MVP - Excel)</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82974</link>
		<dc:creator>Rick Rothstein (MVP - Excel)</dc:creator>
		<pubDate>Fri, 15 Jun 2012 18:31:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82974</guid>
		<description><![CDATA[&gt; Rick: There’s some use for VBA implicit type coercion. {grin}

Yeah, who would have thought... ;-)

&gt; I used it to see what happens with lhm’s suggestion. Clearly VBA does “keep”
&gt; the additional digits around and they appear after the first and second set
&gt; of subtractions in the below code. Then, the third set of subtractions shows
&gt; errors in the least significant digits in the significand.
&gt;
&gt; Public Const AA As Double = &quot;1.7976931348623157E308&quot;

Yes, that does seem to allow you to pump in more precision, but the reason I wrote my comment that started with &quot;Interestingly enough...&quot; was that you cannot do this directly (it produces an overflow error)...

Public Const DoubleMax As Double = &quot;1.79769313486232E308&quot;]]></description>
		<content:encoded><![CDATA[<p>&gt; Rick: There’s some use for VBA implicit type coercion. {grin}</p>
<p>Yeah, who would have thought&#8230; <img src='http://dailydoseofexcel.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
<p>&gt; I used it to see what happens with lhm’s suggestion. Clearly VBA does “keep”<br />
&gt; the additional digits around and they appear after the first and second set<br />
&gt; of subtractions in the below code. Then, the third set of subtractions shows<br />
&gt; errors in the least significant digits in the significand.<br />
&gt;<br />
&gt; Public Const AA As Double = &#8220;1.7976931348623157E308&#8243;</p>
<p>Yes, that does seem to allow you to pump in more precision, but the reason I wrote my comment that started with &#8220;Interestingly enough&#8230;&#8221; was that you cannot do this directly (it produces an overflow error)&#8230;</p>
<p>Public Const DoubleMax As Double = &#8220;1.79769313486232E308&#8243;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82972</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Fri, 15 Jun 2012 17:51:30 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82972</guid>
		<description><![CDATA[Rick:  That&#039;s ingenious.  There&#039;s some use for VBA implicit type coercion. {grin}

I used it to see what happens with lhm&#039;s suggestion.  Clearly VBA does &quot;keep&quot; the additional digits around and they appear after the first and second set of subtractions in the below code.  Then, the third set of subtractions shows errors in the least significant digits in the significand.

Option Explicit
Public Const AA As Double = &quot;1.7976931348623157E308&quot;

Sub doShow()
    Debug.Print &quot;1.7976931348623157E308&quot; &amp; vbNewLine _
        &amp; AA &amp; vbNewLine _
        &amp; (AA - 1E+308) &amp; vbNewLine _
        &amp; (AA - 1E+308 - 7E+307) &amp; vbNewLine _
        &amp; (AA - 1E+308 - 7E+307 - 9E+306)
    End Sub

The results are
1.7976931348623157E308
1.79769313486232E+308
7.97693134862316E+307
9.76931348623157E+306
7.69313486231567E+305]]></description>
		<content:encoded><![CDATA[<p>Rick:  That&#8217;s ingenious.  There&#8217;s some use for VBA implicit type coercion. {grin}</p>
<p>I used it to see what happens with lhm&#8217;s suggestion.  Clearly VBA does &#8220;keep&#8221; the additional digits around and they appear after the first and second set of subtractions in the below code.  Then, the third set of subtractions shows errors in the least significant digits in the significand.</p>
<p>Option Explicit<br />
Public Const AA As Double = &#8220;1.7976931348623157E308&#8243;</p>
<p>Sub doShow()<br />
    Debug.Print &#8220;1.7976931348623157E308&#8243; &#038; vbNewLine _<br />
        &#038; AA &#038; vbNewLine _<br />
        &#038; (AA &#8211; 1E+308) &#038; vbNewLine _<br />
        &#038; (AA &#8211; 1E+308 &#8211; 7E+307) &#038; vbNewLine _<br />
        &#038; (AA &#8211; 1E+308 &#8211; 7E+307 &#8211; 9E+306)<br />
    End Sub</p>
<p>The results are<br />
1.7976931348623157E308<br />
1.79769313486232E+308<br />
7.97693134862316E+307<br />
9.76931348623157E+306<br />
7.69313486231567E+305</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Rothstein (MVP - Excel)</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82959</link>
		<dc:creator>Rick Rothstein (MVP - Excel)</dc:creator>
		<pubDate>Fri, 15 Jun 2012 07:00:03 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82959</guid>
		<description><![CDATA[@Tushar,

Oh, you are going to love this. After I posted my last message, I got to thinking about the way VB coerces values as the need arises. Well, as it turns out, it will coerce a String value to a Currency data type with on trouble. Check this out...

&lt;code&gt;
Public Const CurrencyMax As Currency = &quot;922337203685477.5807&quot;
Public Const CurrencyMin As Currency = &quot;-922337203685477.5808&quot;

Sub Test()
  MsgBox CurrencyMin &amp; &quot; &lt;= AnyCurrencyNumber &lt;= &quot; &amp; CurrencyMax
End Sub
&lt;/code&gt;

Interestingly enough, the above String method did not work for the Double data type and the value discussed earlier.]]></description>
		<content:encoded><![CDATA[<p>@Tushar,</p>
<p>Oh, you are going to love this. After I posted my last message, I got to thinking about the way VB coerces values as the need arises. Well, as it turns out, it will coerce a String value to a Currency data type with on trouble. Check this out&#8230;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Public Const CurrencyMax As Currency = &quot;922337203685477.5807&quot;<br />
Public Const CurrencyMin As Currency = &quot;-922337203685477.5808&quot;<br />
<br />
Sub Test()<br />
&nbsp; MsgBox CurrencyMin &amp; &quot; &lt;= AnyCurrencyNumber &lt;= &quot; &amp; CurrencyMax<br />
End Sub</div></div>
<p>Interestingly enough, the above String method did not work for the Double data type and the value discussed earlier.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Rothstein (MVP - Excel)</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82958</link>
		<dc:creator>Rick Rothstein (MVP - Excel)</dc:creator>
		<pubDate>Fri, 15 Jun 2012 06:41:18 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82958</guid>
		<description><![CDATA[@Tushar,

The fact that Public Const XX As Currency =-922337203685477.5808@ resulted in a Compile Error really surprises me. However, as is usually the case in VB, there is a way to do this with public constants. Put the following in a Standard Module and run the Test subroutine...

&lt;code&gt;
Public Const CurrencyMax As Currency = 922337203685477.5807@
Public Const CurrencyMin As Currency = -CurrencyMax - 0.0001@

Sub Test()
  MsgBox CurrencyMin &amp; &quot; &lt;= AnyCurrencyNumber &lt;= &quot; &amp; CurrencyMax
End Sub
&lt;/code&gt;

Of course, I have no idea what this should work and using the number directly does not... that one has me scratching my head. Also, the code was tested on XL2003 and XL2007 (which contain VBA Versions 6), but I do not have XL2010 install on my computer, so I do not know if it works in that versions VBA Version 7.

Oh, by the way, the @ symbol at the end of the 0.0001 number is not needed as the code works fine without it, but if I was doing it this way, I would feel more comfortable using it so that I did not have to rely on VB to coerce the value from a double (which is how I think VB sees it) to a Currency data type behind the scenes.]]></description>
		<content:encoded><![CDATA[<p>@Tushar,</p>
<p>The fact that Public Const XX As Currency =-922337203685477.5808@ resulted in a Compile Error really surprises me. However, as is usually the case in VB, there is a way to do this with public constants. Put the following in a Standard Module and run the Test subroutine&#8230;</p>
<div class="codecolorer-container text default" style="overflow:auto;white-space:nowrap;border:1px solid #9F9F9F;width:435px;"><div class="text codecolorer" style="padding:5px;font:normal 12px/1.4em Monaco, Lucida Console, monospace;white-space:nowrap">Public Const CurrencyMax As Currency = 922337203685477.5807@<br />
Public Const CurrencyMin As Currency = -CurrencyMax - 0.0001@<br />
<br />
Sub Test()<br />
&nbsp; MsgBox CurrencyMin &amp; &quot; &lt;= AnyCurrencyNumber &lt;= &quot; &amp; CurrencyMax<br />
End Sub</div></div>
<p>Of course, I have no idea what this should work and using the number directly does not&#8230; that one has me scratching my head. Also, the code was tested on XL2003 and XL2007 (which contain VBA Versions 6), but I do not have XL2010 install on my computer, so I do not know if it works in that versions VBA Version 7.</p>
<p>Oh, by the way, the @ symbol at the end of the 0.0001 number is not needed as the code works fine without it, but if I was doing it this way, I would feel more comfortable using it so that I did not have to rely on VB to coerce the value from a double (which is how I think VB sees it) to a Currency data type behind the scenes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lhm</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82957</link>
		<dc:creator>lhm</dc:creator>
		<pubDate>Fri, 15 Jun 2012 06:37:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82957</guid>
		<description><![CDATA[@tushar: I think you misunderstood me as perhaps I wasn&#039;t clear enough. My point is you should specify doubles with 17 significant figures otherwise you will not be storing the maximum value. VBA will accept the longer number I posted and stores this value internally, you can compare against visual studio which does display the extra digits.]]></description>
		<content:encoded><![CDATA[<p>@tushar: I think you misunderstood me as perhaps I wasn&#8217;t clear enough. My point is you should specify doubles with 17 significant figures otherwise you will not be storing the maximum value. VBA will accept the longer number I posted and stores this value internally, you can compare against visual studio which does display the extra digits.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82948</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Fri, 15 Jun 2012 02:37:25 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82948</guid>
		<description><![CDATA[That&#039;s interesting, Rick.  I almost never use the type declaration character so I didn&#039;t think of trying it.

Apparently, the VBE folks also don&#039;t much use it (much). {grin}

As you indicated it works for the maximum currency value.  But with the minimum value

Public Const XX As Currency =-922337203685477.5808@

the result is &quot;Compile error: Expected: expression&quot; and the editor selects the part after the minus sign, i.e., 922337203685477.5808@

So, apparently, the editor/compiler is written to first evaluate 922337203685477.5808@ and then get the negative of that value.  Unfortunately, the first step yields an unacceptable number. ;-)]]></description>
		<content:encoded><![CDATA[<p>That&#8217;s interesting, Rick.  I almost never use the type declaration character so I didn&#8217;t think of trying it.</p>
<p>Apparently, the VBE folks also don&#8217;t much use it (much). {grin}</p>
<p>As you indicated it works for the maximum currency value.  But with the minimum value</p>
<p>Public Const XX As Currency =-922337203685477.5808@</p>
<p>the result is &#8220;Compile error: Expected: expression&#8221; and the editor selects the part after the minus sign, i.e., 922337203685477.5808@</p>
<p>So, apparently, the editor/compiler is written to first evaluate 922337203685477.5808@ and then get the negative of that value.  Unfortunately, the first step yields an unacceptable number. <img src='http://dailydoseofexcel.com/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Rick Rothstein (MVP - Excel)</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82945</link>
		<dc:creator>Rick Rothstein (MVP - Excel)</dc:creator>
		<pubDate>Fri, 15 Jun 2012 00:14:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82945</guid>
		<description><![CDATA[@Tushar,

You can use the @ postfix character to force the assigned number to remain a Currency value...

Public Const xx As Currency = 922337203685477.5807@]]></description>
		<content:encoded><![CDATA[<p>@Tushar,</p>
<p>You can use the @ postfix character to force the assigned number to remain a Currency value&#8230;</p>
<p>Public Const xx As Currency = 922337203685477.5807@</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Tushar Mehta</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82943</link>
		<dc:creator>Tushar Mehta</dc:creator>
		<pubDate>Thu, 14 Jun 2012 23:17:51 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82943</guid>
		<description><![CDATA[Michael:

The definition of the currency data type is a 64 bit integer scaled by 10,000.  Hence, the integer data type classification.

Precision, according to wikipedia (http://en.wikipedia.org/wiki/Significand) is the number of bits in the number.  Consequently, for a double it is 53.  Maybe, what I called &#039;smallest&#039; might be better called &#039;resolution?&#039;  It might fit better with what Nigel describes.


fzz:

Yes, that&#039;s possible.  I took some of the initial functions from a class module and VBA does not allow public constants in a class module.

Another problem with the use of a const is that VBE does unexpected and unnecessary rounding (VBA7, Office 2010 32bit).  E.g.,

public const xx as currency=922337203685477.5807

becomes

Public Const XX As Currency = 922337203685478#


lhm:

Thanks for the explanation of what could be.  Of course, from a practical perspective, since 1.79769313486232E308 in a VBA double raises an overflow error, there&#039;s little choice but to consider the largest value that one can have in a VBA double as 1.79769313486231E308.]]></description>
		<content:encoded><![CDATA[<p>Michael:</p>
<p>The definition of the currency data type is a 64 bit integer scaled by 10,000.  Hence, the integer data type classification.</p>
<p>Precision, according to wikipedia (<a href="http://en.wikipedia.org/wiki/Significand" rel="nofollow">http://en.wikipedia.org/wiki/Significand</a>) is the number of bits in the number.  Consequently, for a double it is 53.  Maybe, what I called &#8216;smallest&#8217; might be better called &#8216;resolution?&#8217;  It might fit better with what Nigel describes.</p>
<p>fzz:</p>
<p>Yes, that&#8217;s possible.  I took some of the initial functions from a class module and VBA does not allow public constants in a class module.</p>
<p>Another problem with the use of a const is that VBE does unexpected and unnecessary rounding (VBA7, Office 2010 32bit).  E.g.,</p>
<p>public const xx as currency=922337203685477.5807</p>
<p>becomes</p>
<p>Public Const XX As Currency = 922337203685478#</p>
<p>lhm:</p>
<p>Thanks for the explanation of what could be.  Of course, from a practical perspective, since 1.79769313486232E308 in a VBA double raises an overflow error, there&#8217;s little choice but to consider the largest value that one can have in a VBA double as 1.79769313486231E308.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lhm</title>
		<link>http://dailydoseofexcel.com/archives/2012/06/12/minimum-and-maximum-values-of-numeric-data-types/#comment-82884</link>
		<dc:creator>lhm</dc:creator>
		<pubDate>Thu, 14 Jun 2012 16:35:16 +0000</pubDate>
		<guid isPermaLink="false">http://www.dailydoseofexcel.com/?p=7105#comment-82884</guid>
		<description><![CDATA[&gt;The documentation incorrectly indicates the largest double is 1.79769313486232E308

...Actually the documentation is correct but the result is rounded to 15sf, The maximum value is ?[2^1023*(2-2^-52)]. This highlights the need for more than 15sf in specifying values, in this case: 1.7976931348623157E308. Note also that VBA uses subnormal numbers for the lower limits but Excel rounds these to zero.]]></description>
		<content:encoded><![CDATA[<p>&gt;The documentation incorrectly indicates the largest double is 1.79769313486232E308</p>
<p>&#8230;Actually the documentation is correct but the result is rounded to 15sf, The maximum value is ?[2^1023*(2-2^-52)]. This highlights the need for more than 15sf in specifying values, in this case: 1.7976931348623157E308. Note also that VBA uses subnormal numbers for the lower limits but Excel rounds these to zero.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
