BUG: Probs Using Long Integers in Mac QuickBasic 1.00 (60862)






This article was previously published under Q60862

SYMPTOMS

This article documents several cases where the product of a long integer and another number can be incorrect in Microsoft QuickBasic Version 1.00 for the Macintosh . This problem occurs only in the interpreter, not in a compiled program.

Microsoft has confirmed this to be a bug in QuickBasic 1.00 for the Macintosh . We are researching this problem and will post new information here in the Microsoft Knowledge Base as it becomes available.

MORE INFORMATION

To work around the problem, either compile the code or change one of the variables to a single- or a double-precision number. The table below summarizes the values that X and Y can take on in the code example and whether or not the expression fails.

Reproducing the problem only requires a three-line program with two variables. The data type of the two variables should be as described in the chart below. Consider the following three-line program:
      X = <some value -- see the chart>
      Y = <some value -- see the chart>
      PRINT X * Y
				
This program produces incorrect results if X is a long integer with a value of 65536& and Y is a long integer with a value of -1. In this case, X will not be negative.

In the following chart

  1. "MAX" means the largest possible value that type of number can have.
              MAX Long:   2,147,483,647
              MAX Sing:   3.37+38
              MAX Double: 1.67D+308
    						
  2. "MIN" means the smallest possible value that type of number can have.
              MIN Long:   -2,147,483,648
              MIN Sing:   -3.37E+38
              MIN Double: -1.67D+308
    						
  3. "Long" means long-integer variable.
  4. "Sing" means single-precision variable. Double means double-precision variable.
                  X                   Y              Problem ?
        -------------------   ----------------       ---------
    
         65536& to MAX Long   Negative Long          Yes
    
        -65536& to MIN Long   Negative Long          Yes
    
         65536& to MAX Long   Negative Integer       Yes
    
        -65536& to MIN Long   Negative Integer       Yes
    
         65536& to MAX Sing   Negative Long          No
             or Double
    
        -65536& to MIN Sing   Negative Long          No
             or Double
    
         65536& to MAX Long   Negative Sing          No
                                or Double
    
        -65536& to MIN Long   Negative Sing          No
                                or Double

Modification Type: Minor Last Reviewed: 1/8/2003
Keywords: kbbug KB60862