SQLite query where clause with floating point numbers fails?

后端 未结 5 1400
死守一世寂寞
死守一世寂寞 2021-01-13 07:03

I\'m putting a float in an Android based SQLite database, like so:

private static final String DATABASE_CREATE = 
    \"create table \" + DATABASE_TABLE + \"         


        
5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-13 07:30

    Granted, it's a bad idea to compare float values for equality.

    Howver, I see that SQLite uses 8-byte floating point values (which is like a DOUBLE), so it's odd that 37.0 is considered equal to 37.3. Unless you modified for your example the values used in the actual code?

    You could store your LATITUDE as integers, in tenth of degree, applying the precision yourself, and converting the value on read/write...

提交回复
热议问题