On Thu, Jan 8, 2009 at 7:03 PM, Gerry Snyder <mesmerizer...@gmail.com> wrote: > Sander Jansen wrote: >> I need to store NaNs in my database and able to retrieve them as well. >> >> Since sqlite will give me back 0.0 when I call sqlite3_column_double >> and a result contains a NAN, >> I was wondering what the best way is to retrieve a NAN from the database. >> >> Here's what I currently do in peudo code: >> >> if (sqlite3_column_type(column)==SQLITE_FLOAT) >> value = sqlite3_column_double(column); >> else >> value = NAN; >> >> Now, the doc says that >> >> "The value returned by sqlite3_column_type() is only meaningful if no >> type conversions have occurred as described below." >> >> Am I correctly assuming the "no type conversions have occurred" means >> "no type conversions on that (row,column) of the result set"? I mean >> next time I call sqlite3_column_type() on the same column but on the >> next row of the result set, it will still give the correct answer? >> >> Thanks, >> >> Sander >> > That sounds correct, yes. > > One suggestion--if the column will always have either a float or NAN, > why not just not insert anything if you have NAN, and then test for NULL? >
I see your point, but the query is already a prepared statement. So having a double as input, I can either check for a NAN and do a bind_null in that case, or just don't check it at all and do a bind_double. Even in your suggested case, I would need to check whether or not the double is a NaN or not. So I take it the easy way and always do a bind_double. Sander _______________________________________________ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users