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

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


There's no such thing as a floating-point integer. They're mutually exclusive on a fundamental level (well floating point numbers can fall on integer boundaries but you get the idea) :P.

But the way to get floats out is by using the sqlite3_column_double(sqlite3_stmt *, int) function.

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


Declare the fields as a floating point number. From sqllite datatype doc the database type is REAL. This is a 8 byte floating point number which is an Objective-C double, NSDouble or NSNumber type.


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

This code worked for me..