KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q57483: The Suffix "F" or "f" Causes a Syntax Error for Floats

Article: Q57483
Product(s): See article
Version(s): 2.00 2.01
Operating System(s): MS-DOS
Keyword(s): ENDUSER | docerr s_quickasm | mspl13_c
Last Modified: 17-JAN-1990

On Page 50 (third entry from the bottom of Table 4.2) and Page 51
(second paragraph) of the "C For Yourself" manual, it incorrectly
states that a float can be a number that has the suffix "F" or "f".
For example:

   float a = 123F;

This causes the following error at compile time:

   C2061: syntax error:

The correct syntax is as follows:

   float a = 123.0F
or
   float a = 123.F
or
   float a = 123e0F

According to the ANSI specifications (3.1.3.1 Floating constants), "F"
and "f" are used to force a variable to be a float instead of a
double. However, the suffix alone is not enough and the decimal point
or "e" notation is required.

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.