Microsoft KB Archive/34292

From BetaArchive Wiki
Knowledge Base


Understanding Floating-Point Differences in Mac QuickBASIC

Article ID: 34292

Article Last Modified on 1/9/2003



APPLIES TO

  • Microsoft QuickBasic Compiler for Macintosh 1.0



This article was previously published under Q34292

SUMMARY

The following information applies to the Microsoft QuickBASIC Compiler Version 1.00 for the Apple Macintosh.

To increase efficiency, the compiler uses different floating-point arithmetic routines than the QuickBASIC interpreter environment. As a result, equivalent floating-point expressions may produce slightly different values in a compiled application compared to running in the QuickBASIC environment.

MORE INFORMATION

The following examples show that although binary versions calculate to more decimal places, the decimal versions are more accurate. The following source code produces slightly different values, as shown in the four sets of output:

  s1! = 33 : s2! = 13 : s3! = 3
  s4! = SIN (s1!/s2!) * (TAN (s2! * s3!) ^ 3)
  d1# = 33 : d2# = 13 : d3# = 3
  d4# = SIN (d1#/d2#) * (TAN (d2# * d3#) ^ 3)
  PRINT "Single"; s4!, "Double "; d4#
  END
                

Output from the QuickBASIC environment (binary version):

Single 26.78669 Double 26.78667677467639


Output from compiled application (binary version):

Single 26.78668 Double 26.78669793504293


Output from QuickBASIC environment (decimal version):

Single 26.7867 Double 26.786676774842


Output from compiled application (decimal version):

Single 26.7866 Double 26.786578796841



Additional query words: MQuickB

Keywords: KB34292