Q62830: X=(-1*W)^2 Gives "Division by Zero" on 386 with 387; BASIC 7.1
Article: Q62830
Product(s): See article
Version(s): 7.00 7.10 | 7.00 7.10
Operating System(s): MS-DOS | OS/2
Keyword(s): ENDUSER | buglist7.00 buglist7.10 | mspl13_basic
Last Modified: 6-AUG-1990
Executing the following line of code on a 80386 machine equipped with
an 80387 math coprocessor results in a "Division by zero" error:
X = (-1 * W) ^ 2
The "Division by zero" error occurs in both the QBX.EXE environment
and within a compiled .EXE in Microsoft BASIC Professional Development
System (PDS) versions 7.00 and 7.10. The error occurs only on 80386
computers with 80387 coprocessors.
Microsoft has confirmed this to be a problem with Microsoft BASIC
Professional Development System (PDS) versions 7.00 and 7.10 for
MS-DOS and MS OS/2. We are researching this problem and will post new
information here as it becomes available. This problem does not occur
with other Microsoft BASIC products.
The following are two workarounds for the above problem:
1. Use the DOS command SET NO87=NONE to disable BASIC's use of the 387
coprocessor. The program will then execute correctly. Note that
disabling BASIC's use of the coprocessor usually slows program
execution.
2. Change the line of code into two lines, using a temporary variable
to hold the value of (-1 * W), as follows:
TEMP = (-1 * W)
X = TEMP ^ 2
THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.
Copyright Microsoft Corporation 1986-2002.