Microsoft KB Archive/43566

From BetaArchive Wiki
Knowledge Base

BUG: Double Precision to Power of Integer Var Fails Compiled

Article ID: 43566

Article Last Modified on 11/21/2006

This article was previously published under Q43566


Raising a double-precision number to the power of an integer variable incorrectly returns zero in the program below when compiled in Microsoft QuickBasic Version 1.00 for Macintosh .

The problem occurs in either the Binary math [QuickBasic (b)] or the Decimal math [QuickBasic (d)] versions of the compiler. The problem does not occur in the interpreter in QuickBasic. Microsoft is researching this problem and will post new information as it becomes available.

To work around the problem, raise the double-precision number to the power of a non-integer variable, such as a double-precision variable or a constant of any precision.


The program compiled in QuickBasic incorrectly returns "0" (zero) for the following expression:

   D# ^ i%

However, the following correct result is produced for the expression:

  D# ^ j#

The problem does not occur in Microsoft Basic Compiler Version 1.00 for the Macintosh (released earlier than QuickBasic), which correctly produces 12 digits of precision for both expressions.

The following code example produces two printouts of a number raised to the power of 2; the first one improperly returns "0" and the second correctly returns a value with 12 digits of precision.

Example Code:

D# = RND( 1)
J# = 2
i% = J#
print D# ^ i%,  D# ^ J#

Additional query words: MQuickB

Keywords: kbbug KB43566