Microsoft KB Archive/71568

= BUG: Bad Floating-Point Result When Using STATIC Array =

Article ID: 71568

Article Last Modified on 10/20/2003

-

APPLIES TO


 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft QuickBasic Compiler for Macintosh 1.0
 * Microsoft QuickBasic Compiler for Macintosh 1.0

-



This article was previously published under Q71568



SYMPTOMS
Creating a STATIC array in a program compiled under the binary version of Microsoft QuickBasic for the Macintosh may cause incorrect results from double-precision floating-point calculations.

Microsoft has confirmed this problem in the Binary (b) version of Microsoft QuickBasic versions 1.00, 1.00a, 1.00b for Macintosh. Microsoft is researching this problem and will post new information here as it becomes available.



MORE INFORMATION
Arrays can be made STATIC using the DIM STATIC statement or by compiling with the &quot;Make all arrays STATIC&quot; compile option.

The following code demonstrates the problem: DIM STATIC s$(10000) ' Problem also with:  DIM STATIC x(10000) a#=123456789.12 b#=b#+a# PRINT a#       PRINT b# This should result in two identical values being printed to the screen, but instead, the value of b# is incorrect.

You can do any of the following to work around the problem:

 Do not dimension the array as STATIC. Make the array smaller than 10000 elements. Change the order of the variables in the calculation. For example, the following gives the correct results:

b# = a# + b#

Using a temporary variable also gives the correct results, as follows:

c# = b# + a#

b# = c#

 Use single precision variables instead of double precision.

This problem occurs only in an application compiled under the binary version of Microsoft QuickBasic for the Macintosh. The problem does not occur in the interpreter under the binary version, and does not occur at all in the decimal version of Microsoft QuickBasic for Macintosh.

Additional query words: MQuickB

Keywords: kbbug KB71568

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.