FIX: Floating Point Field Incorrectly Assigned -9.123E+19Last reviewed: September 18, 1997Article ID: Q125465 |
1.51 1.52
WINDOWS
kbprg kbbuglist kbfixlist
The information in this article applies to:
SYMPTOMSWhen you use the RFX_Single() function and set a field to null, the field may actually be set to -9.123E+19 rather than null. For example, the following code doesn't set the field to null as expected.
CYourRecordset rs; rs.Open(); rs.Edit(); rs.SetFieldNull(&rs.m_floatfield); rs.Update(); rs.Close(); CAUSEThe problem is caused by a bug in the MFC database classes. Specifically, the RFX_Single() function performs an incorrect check to see if a field is null. Looking at DBFLT.CPP in the MSVC15\MFC\SRC directory, you'll see this:
case CFieldExchange::MarkForUpdate: if (value != AFX_RFX_SINGLE_PSEUDO_NULL) pFX->m_prs->ClearFieldFlags(nField, AFX_SQL_FIELD_FLAG_NULL, pFX->m_nFieldType); goto LDefault;The code doesn't work correctly because AFX_RFX_SINGLE_PSEUDO_NULL is defined in AFXDB.H as this:
#define AFX_RFX_SINGLE_PSEUDO_NULL (-9.123e19)It should be defined as this:
#define AFX_RFX_SINGLE_PSEUDO_NULL (-9.123e19f)As you can see the code compares a float to a double, so the comparison will never be true.
RESOLUTIONTo work around this problem, follow these steps:
STATUSMicrosoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article. This problem was corrected in Microsoft Visual C++, 32-bit Edition, version 2.2.
|
Additional reference words: 1.51 1.52 2.51 2.52 ODBC numeric number
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |