Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SQLite saves float values in integer

I'm using System.Data.SQLite to save data to database. In table there are 2 columns defined as float. However when I save data to DB it saves only integer part.

12.2345 => 12 11.5324 => 11 (I don't know how exactly it rounds, it just rounds)

Yes I'm sure I'm using floats in my application, and I'm sure that CommandText contains float numbers NOT integer.

like image 218
mnn Avatar asked Dec 29 '25 14:12

mnn


1 Answers

You need to be using floats in your application, but you also need to make sure the table entry in the SQLite database has been explicitly declared to be that REAL type.

like image 81
Paul Hsieh Avatar answered Jan 01 '26 03:01

Paul Hsieh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!