Microsoft KB Archive/191327

= FIX: Double Value Returned from DLL Gets Decimal Portion of 0 =

Article ID: 191327

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Visual FoxPro 3.0 Standard Edition
 * Microsoft Visual FoxPro 3.0b Standard Edition
 * Microsoft Visual FoxPro 5.0 Standard Edition
 * Microsoft Visual FoxPro 5.0a

-



This article was previously published under Q191327



SYMPTOMS
If you create a .dll file that contains an exported function, which returns a value of type Double, when you declare and call this function from Visual FoxPro, any decimal portion of the return value is set to 0.



STATUS
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This bug has been corrected in Visual FoxPro 6.0.



Steps to Reproduce Behavior
  In Microsoft Visual C++, create test2.cpp which will contain the following code: //test2.cpp #include 

BOOL APIENTRY DllMain(HANDLE hInst, DWORD ul_reason_to_call, LPVOID  lpReserved) {         return TRUE; UNREFERENCED_PARAMETER(hInst); UNREFERENCED_PARAMETER(ul_reason_to_call); UNREFERENCED_PARAMETER(lpReserved); };

double APIENTRY test(double p1, double p2) {      return p1 * p2; };                         Create a file called Test2.DEF with the following contents: ; test2.def : Declares the module parameters for the DLL.

LIBRARY     "Test2" DESCRIPTION 'Test2 Dynamic Link Library'

EXPORTS test @4  Build Test2.dll as a Multithreaded .dll file. In Visual FoxPro, set the directory containing the .dll built in Step 4 as the default directory.  Run the following from the Command window: DECLARE DOUBLE test IN test2.dll DOUBLE, DOUBLE ? test(1.5, 1.5) ? test(2.5, 2.5) You will get return values of:

2.00

6.00

</ol>

Any decimal portion of the double value returned from the .dll function will be 0.

<div class="references_section">