KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q43309: PRINT USING Incorrect Results, Hang for Double Precision

Article: Q43309
Product(s): See article
Version(s): 4.00 4.00b 4.50
Operating System(s): MS-DOS
Keyword(s): ENDUSER | buglist4.00 buglist 4.00b buglist4.50 SR# S890319-2 B_BasicC | mspl13_basic
Last Modified: 26-FEB-1990

PRINT USING for double precision numbers assigned to an expression in
the range of (&H1D - 128) to (&H1D - 256) (where hex and decimal
notations are mixed) can produce incorrect results in the program
below. In the QB.EXE editor, it ignores the format string and prints a
very large number. When compiled to an executable .EXE, it produces
varied results depending on the version of the compiler and the
options used. Compiling for Debug (with BC /d) does not affect the
result.

The following program, when compiled with BC.EXE Version 4.00 for use
with BRUN, or with 4.00b, 6.00, or 6.00b for use with BCOM, prints
large numbers as it does in the editor, but does not hang. When
compiled with BC.EXE 4.00b, 4.50, 6.00, or 6.00b for use with BRUN, it
prints very large numbers, and if run twice, it hangs the machine.
When compiled with /O with BCOM in 4.00 and 4.50, it prints garbled
output to the screen, but does not hang the machine.

Microsoft has confirmed this to be a problem in Microsoft QuickBASIC
Versions 4.00, 4.00b, and 4.50, and in Microsoft BASIC Compiler
Versions 6.00 and 6.00b (buglist6.00, buglist6.00b) for MS-DOS and MS
OS/2. This problem was corrected in Microsoft BASIC Professional
Development System (PDS) Version 7.00 (fixlist7.00).

Code Example
------------

' You can substitute "#" for each
' double precision number with the same result.
DEFDBL A-Z
CLS

j = &H1D - 128

FOR i = 1 TO 128
  j = j / 10
  PRINT USING "##.#######"; j
  NEXT
END

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.