Re: [sqlite] Datetime issue with the time part

2008-07-15 Thread Sebastien Robillard
Eric Minbiole wrote:
> From what you describe, it seems that the compiler is performing 
> single-precision, rather than double-precision, math.  After a quick 
> Google search, I found a few posts indicating that Direct3D silently 
> switches the FPU from double to single precision math, presumably in 
> order to improve performance.
>
> While it seems nearly unconscionable that a graphics library would mess 
> with the FPU, the good news is that it appears you can override this 
> default behavior when creating a 3D device.  See "FpuPreserve" flag:
>
> http://msdn.microsoft.com/en-us/library/bb153282(VS.85).aspx
>
> Hope this helps,
>   Eric
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>   

That was exactly the problem, using the FpuPreserve flag I have no 
problems at all. Thanks for your help.

- Sebastien R.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Datetime issue with the time part

2008-07-14 Thread Eric Minbiole
> Once again, all of these problems doesn't happen before the creation of 
> the Direct3D device. Does anyone ever used SQLite successfully in a 
> full-screen 3D game ?

 From what you describe, it seems that the compiler is performing 
single-precision, rather than double-precision, math.  After a quick 
Google search, I found a few posts indicating that Direct3D silently 
switches the FPU from double to single precision math, presumably in 
order to improve performance.

While it seems nearly unconscionable that a graphics library would mess 
with the FPU, the good news is that it appears you can override this 
default behavior when creating a 3D device.  See "FpuPreserve" flag:

http://msdn.microsoft.com/en-us/library/bb153282(VS.85).aspx

Hope this helps,
  Eric
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Datetime issue with the time part

2008-07-14 Thread Sebastien Robillard
Eric Minbiole wrote:
> Sebastien Robillard wrote:
>   
>> Hi everyone,
>>   I have an issue with datetimes that doesn't return the "time" part 
>> correctly (always 00:00:00 or 18:00:00) when I use SQLite in my C++ 
>> code. Whenever I use datetime('now'), or current_timestamp, the time is 
>> not correct. However, it works correctly when using the sqlite3 program 
>> (sqlite-3_5_9.zip from download page). Right now I use the SQLite dll 
>> (sqlitedll-3_5_9.zip) in my code, but I also tried with the source code 
>> amalgamation with the same results 
>> 
>
> Your code looked correct, so I tried to reproduce the problem:  I 
> complied the sample code you provided using Visual Studio 2005 and the 
> v3.5.9 amalgamation.  Running under XP, I got the expected result:
>
> DATETIME('NOW') = 2008-07-14 18:29:49
>
> I assume that you are running under some flavor of Windows, since you 
> are using sqlitedll.  Perhaps start by adding some traces to SQLite 
> function "winCurrentTime()"?
>
> Good luck,
>   Eric
> ___
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
>   
What I omit to tell earlier is that I use SQLite to save some data for a 
game. After tracing my code a bit more, and after checking the 
winCurrentTime function as you proposed, I realized that the problem 
occurs only AFTER the creation of my Direct3D 9 device. Before that 
point, the dates works correctly. Once  my device is created, the 
numbers goes all wrong. I traced the winCurrentTime function and saw 
that there is errors in calculations. For exemple, this line
*prNow = (now + ft.dwLowDateTime)/8640.0 + 2305813.5;
gives me these numbers
*prNow = 148848.828125 + 2305813.5;
The result inside prNow is 2454662.25

Once again, all of these problems doesn't happen before the creation of 
the Direct3D device. Does anyone ever used SQLite successfully in a 
full-screen 3D game ?

Thanks for your help,

- Sebastien R.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] Datetime issue with the time part

2008-07-14 Thread Eric Minbiole
Sebastien Robillard wrote:
> Hi everyone,
>   I have an issue with datetimes that doesn't return the "time" part 
> correctly (always 00:00:00 or 18:00:00) when I use SQLite in my C++ 
> code. Whenever I use datetime('now'), or current_timestamp, the time is 
> not correct. However, it works correctly when using the sqlite3 program 
> (sqlite-3_5_9.zip from download page). Right now I use the SQLite dll 
> (sqlitedll-3_5_9.zip) in my code, but I also tried with the source code 
> amalgamation with the same results 

Your code looked correct, so I tried to reproduce the problem:  I 
complied the sample code you provided using Visual Studio 2005 and the 
v3.5.9 amalgamation.  Running under XP, I got the expected result:

DATETIME('NOW') = 2008-07-14 18:29:49

I assume that you are running under some flavor of Windows, since you 
are using sqlitedll.  Perhaps start by adding some traces to SQLite 
function "winCurrentTime()"?

Good luck,
  Eric
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] Datetime issue with the time part

2008-07-14 Thread Sebastien Robillard
Hi everyone,
  I have an issue with datetimes that doesn't return the "time" part 
correctly (always 00:00:00 or 18:00:00) when I use SQLite in my C++ 
code. Whenever I use datetime('now'), or current_timestamp, the time is 
not correct. However, it works correctly when using the sqlite3 program 
(sqlite-3_5_9.zip from download page). Right now I use the SQLite dll 
(sqlitedll-3_5_9.zip) in my code, but I also tried with the source code 
amalgamation with the same results 

*SQLite3:*
sqlite> SELECT DATETIME('NOW');
2008-07-14 17:41:56
sqlite>


*From my program:*
static int callbackExec(void *NotUsed, int argc, char **argv, char 
**azColName)
{
for(int i = 0; i < argc; i++)
{
std::stringstream ss;
ss << azColName[i] << " = " << argv[i] ? argv[i] : "NULL";
LogEngine::LogError(ss.str().c_str());
}

return 0;
}

void testDatetime()
{
std::string selectDateTime = "SELECT DATETIME('NOW')";
if( sqlite3_exec(mSQLiteDatabase, selectDateTime.c_str(), 
callbackExec, 0, ) != SQLITE_OK )
{
...
}
}

Result:
DATETIME('NOW') = 2008-07-14 18:00:00


I really have no clue why it would do that.

- Sebastien R.
___
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users