BUG: Bad Floating-Point Result When Using STATIC Array (71568)



The information in this article applies to:

  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0a
  • Microsoft QuickBASIC Compiler for the Apple Macintosh 1.0b

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 "Make all arrays STATIC" 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:

  1. Do not dimension the array as STATIC.
  2. Make the array smaller than 10000 elements.
  3. 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#

  4. 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.

Modification Type:MajorLast Reviewed:10/20/2003
Keywords:kbbug KB71568