Question

Hi every one I am using green DAO library for creating and manipulating database and I have some fields in database like

     Float total;

when I am trying to insert values 25.4 it is storing 25.4099998474121

Afterwards when I retrieve data from database I am getting 25.4099998474121 and eventually all my calculations going wrong

please help me get out of this

Thank you

No correct solution

OTHER TIPS

While creating Sqlite table give the floating point field type as decimal(15,2). Here 2 specifies number of decimal points and 15 represents total number of digits allowed.

I tried with the following code and it works perfectly,

create table testing(numberField decimal(15,2))
insert into testing values(9999999999999.99)

but adding more values will round off.

In your case you need to insert,

insert into testing values(25.4)

this inserts the values as 25.4 exactly in sqlite database. If this doesn't work then your program is assigning extra values or rounding off.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top