KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q130350: TYPE() Returns "N" for Double, Float, and Integer

Article: Q130350
Product(s): Microsoft FoxPro
Version(s): WINDOWS:3.0
Operating System(s): 
Keyword(s): kbcode
Last Modified: 11-FEB-2000

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual FoxPro for Windows, version 3.0 
-------------------------------------------------------------------------------

SUMMARY
=======

In Visual FoxPro for Windows, a field may be given the TYPE B for Double, and F
for Float, but the TYPE() function always returns "N" (Numeric) for Double,
Float, and Integer data types.

MORE INFORMATION
================

Sample Code
-----------

The following code demonstrates this:

     ***TYPETEST.PRG***
     CLEAR
     CREATE CURSOR SYS(2015) (bField B(6),fField F(16,8),yField Y)
     INSERT INTO (ALIAS()) VALUES (111.111, 222.222, 333.333)
     ? "The types are: Created Double="+TYPE("bField")+", Created Float=";
     + TYPE("fField")+", Created Currency="+ TYPE("yField")

Here is the result:

  "The types are: Created Double=N, Created Float=N, Created Currency=Y"

Why Numeric Is Always Returned
------------------------------

The Float type is included for compatibility only. It is functionally equivalent
to Numeric. The Double type is relevant only in a table, denoting how the field
data is stored to disk.

All Float types are stored internally as Doubles, converted to ASCII when written
to disk, and then converted back when read. This can result in a loss of
accuracy, so a Double type field is stored as an 8-byte binary value to avoid
inaccuracies.

Additional query words: VFoxWin character

======================================================================
Keywords          : kbcode 
Technology        : kbVFPsearch kbAudDeveloper kbVFP300
Version           : WINDOWS:3.0

=============================================================================

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.