Android development - SQLite storing float Android development - SQLite storing float sqlite sqlite

Android development - SQLite storing float


Never thought this thread will help anybody else, but allas here it goes.

Basically your problem is that you use float for the type in the java code. Float is with very low precision. Read the thread I link to, together with all comments and the linked chat. If you still have any problems write back.

You probably know that the double values are stored only upto certain precision in the computers. Even though the values look weird in the database, this is the best approximation of your values you can get when using float. With double you can increase the precision, but you will never get to perfect state. Maybe if you insist on getting precise values limiting the real size in the database might be a way to go.

EDIT As I could not make you believe it IS a precision problem I include the following program:

float f = 22.2;printf("The number is: %.9f\n", f);

The output is:

22.200000763

I suggest you try it. As you can see this is exactly the number you point out.