The information in this article applies to:
SUMMARYDLLFloat.exe is a sample file that contains a DLL- compatible function to convert a floating-point number to a character string. A small or medium model dynamic-link library (DLL) cannot use any of the C run-time functions provided with Microsoft C version 6.0 to convert a floating-point number to a character string. However, with Microsoft C/C++ version 7.0 you can use the fcvt() and ecvt() functions. The Windows wsprintf() function does not provide any assistance because wsprintf() does not support floating-point numbers. Therefore, a DLL must be compiled with Microsoft C/C++ version 7.0 or provide its own code to perform the conversion. MORE INFORMATIONThe following files are available for download from the Microsoft
Download Center. Click the file names below to download the files: http://www.microsoft.com/downloads/search.aspand then click How to use the Microsoft Download Center. In the Windows environment, an application can use the C run-time functions ecvt, fcvt, gcvt, and sprintf to convert a floating-point number to a character string. However, none of these functions can be used in a DLL because a DLL's data segment is not equal to its stack segment and the design of each function assumes that the two segments are identical. To work around this assumption, a DLL must contain its own code to perform the conversion. The DLLFLOAT example in the Microsoft Software Library creates a function called ConvertFltToStr to convert a number of the DOUBLE data type to a character string. Even though ConvertFltToStr is a self-contained function, DLLFLOAT contains a supporting function, MYfrexp, that works around a problem in the small and medium model Microsoft C 6.0 run-time libraries. ConvertFltToStr calls the frexp function to retrieve the mantissa and exponent of the floating-point number. However, there is a problem with the frexp function in the Microsoft C 6.0 small and medium model DLL run-time libraries. For more information on this problem, please query on the following words in the Microsoft Knowledge Base: frexpThe ConvertFltToStr and MYfrexp functions can be easily incorporated into a DLL. All required variables and manifest constants are declared inside each function. The DLL must declare a global or static string variable to accept the results of the conversion and must include some standard C run-time header files. If the floating-point number is of an order of magnitude greater than 10 or less than negative 10, ConvertFltToStr converts the number using scientific notation. Different formatting can be achieved by modifying the code. Additional query words:
Keywords : kbfile kbsample kb16bitonly kbDLL kbKernBase |
Last Reviewed: December 3, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |