Changeset 8113
- Timestamp:
- Aug 3, 2006, 4:16:58 PM (20 years ago)
- File:
-
- 1 edited
-
trunk/psLib/src/db/psDB.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/db/psDB.c
r8112 r8113 12 12 * @author Joshua Hoblitt 13 13 * 14 * @version $Revision: 1.7 4$ $Name: not supported by cvs2svn $15 * @date $Date: 2006-08-04 02: 01:56$14 * @version $Revision: 1.75 $ $Name: not supported by cvs2svn $ 15 * @date $Date: 2006-08-04 02:16:58 $ 16 16 * 17 17 * Copyright (C) 2005-2006 Joshua Hoblitt, University of Hawaii … … 23 23 #include <stdarg.h> 24 24 #include <string.h> 25 #include <float.h> 25 26 #undef __STRICT_ANSI__ 26 27 #include <stdlib.h> … … 1581 1582 1582 1583 // stringify the psMetadataItem into a SQL search specification 1584 // XXX we're making a big assumption here that the MySQL server handles 1585 // floating point in the exact same way as the client. This is a bit scary 1586 // as MySQL uses native types on the server end. In theory all IEEE754 1587 // math is the same but know that isn't always the case. At least forcing 1588 // the comparison to be done on the server provides some consistency 1589 // between clients on different archs. 1583 1590 if ((item->type == PS_DATA_S32) || (item->type == PS_TYPE_S32)) { 1584 1591 psStringAppend(&query, "%s=%d", item->name, (int)(item->data.S32)); 1585 1592 } else if ((item->type == PS_DATA_F32) || (item->type == PS_TYPE_F32)) { 1586 psStringAppend(&query, " %s=%g", item->name, (double)(item->data.F32));1593 psStringAppend(&query, "ABS(%s - %d) < %f.6", item->name, (int)(item->data.S32), FLT_EPSILON); 1587 1594 } else if ((item->type == PS_DATA_F64) || (item->type == PS_TYPE_F64)) { 1588 psStringAppend(&query, " %s=%g", item->name, (double)(item->data.F64));1595 psStringAppend(&query, "ABS(%s - %d) < %f.10", item->name, (int)(item->data.S32), DBL_EPSILON); 1589 1596 } else if ((item->type == PS_DATA_BOOL) || (item->type == PS_TYPE_BOOL)) { 1590 1597 psStringAppend(&query, "%s=%d", item->name, (int)(item->data.B));
Note:
See TracChangeset
for help on using the changeset viewer.
