Microsoft KB Archive/75537

{|
 * width="100%"|

DLLFloat.exe Converts Floating-Point Numbers to Strings

 * }

Q75537

-

The information in this article applies to:


 * Microsoft Windows Software Development Kit (SDK) versions 3.0, 3.1

-

SUMMARY
DLLFloat.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 INFORMATION
The following files are available for download from the Microsoft Download Center:

DLLFloat.exe

For additional information about how to download Microsoft Support files, click the article number below to view the article in the Microsoft Knowledge Base:

"Q119591 How to Obtain Microsoft Support Files from Online Services" Microsoft used the most current virus detection software available on the date of posting to scan this file for viruses. Once posted, the file is housed on secure servers that prevent any unauthorized changes to the file.

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:

"frexp" The 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

Issue type :

Technology : kbAudDeveloper kbWin3xSearch kbSDKSearch kbWinSDKSearch kbWinSDK300 kbWinSDK310