How do you read floating numbers (REAL) from sqlite database on iphone?

I need to read decimal floating point numbers from sqlite db

I created a variable type in the database as INTEGER

I am reading with sqlite3_column_int NSInteger variables

which parts should be changed, so I can read floating point integers from the database

thanks for the answers sorry im new to this thread

+5
source share
4 answers

There is no such thing as a floating point integer. They are mutually exclusive on a fundamental level (floating point numbers can fall on whole boundaries, but you get the idea): P.

- sqlite3_column_double(sqlite3_stmt *, int).

NSNumber *f = [NSNumber numberWithFloat:(float)sqlite3_column_double(stmt, col)];
+13

. sqlite datatype doc REAL. 8- , Objective-C double, NSDouble NSNumber.

+5
NSNumber *num;
int temp = (float)sqlite3_column_double(walkstatement, 3);
num = [[NSNumber alloc]initWithInt:temp];
NSLog(@"%@",num);

.

+2

sqlite3 . :

  • NULL
  • INTEGER
  • BLOB

sqlite (, ), , .

http://www.sqlite.org/datatype3.html

functions that return doubles, ints, etc., are part of the sqlite C API, trying to give you what you want .... so what is stored in the column can be converted by sqlite if you ask for differs from that in db.

http://www.sqlite.org/c3ref/column_blob.html

about halfway down, there is a handy table that lets you know what to expect.

-1
source

All Articles