I've picked up a project that has an issue. It uses C# with a SQLiteCommand, SqLiteParameters etc. to write a set of floats (singles) to a SQLite database. Subsequently, it reads the values back but reads and exposes them as doubles. (I don't know why there's a discrepancy at this point).

What I'm seeing is that floats rounded to 2DPs in C# are coming back into the doubles with a load of extra high precision decimal place values. E.g. I save 5.20, what I get back is 5.1999998092651300. Or I save 4.90, I get back 4.9000000953674300.

Interestingly, I don't even need to wait until the value comes back into a double before I see the problem. I've been using a SQLite viewer to look at the data and it's had the extra DPs added.

I know SQL Server Reals and Floats are "approximate". I.e. they can get extra high precision DPs drifting like this. My hunch is that this is what's happening inside SQLite, too, but I can't find anything in the documentation to confirm either way.

Does anyone know for sure what SQLite's behaviour is on this?