-1

I'm saving float data in sqlite trough in my aplicaton. The problem is that when I saving the value 99999.99 the sqlite is rounding it to 100000.00. And the same is happening when i try to save 999999.99, its rounding it to 1000000.00. What is happening? The problem is in the Table "custo".

public static final String fghs_CREATE_TABLE = "CREATE TABLE IF NOT EXISTS " +
   asdfgasfdg + " (" +      
    cust + " double, " +
Roland
  • 826
  • 2
  • 9
  • 24

2 Answers2

0

it seems your sqlite table's column type is integer. If so then use REAL as the data type.

stinepike
  • 54,068
  • 14
  • 92
  • 112
0

You should change the float variable in java to a double, which has a higher precision. The following answer explains the problem.

As pointed out in this answer, the following is a nice example of float precision:

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

The output is:

22.200000763
Community
  • 1
  • 1
Jeffrey Klardie
  • 3,020
  • 1
  • 18
  • 23