I need to read floating point decimals from sqlite db
I have created Variable type in database as INTEGER
I am reading with sqlite3_column_int to NSInteger variables
which parts should changed so i can read floating point integers from database
thanks for answers sorry im a newbie in this topics
Apple uses SQLite in many (most?) of the native applications running on Mac OS-X desktops and servers and on iOS devices such as iPhones and iPods. SQLite is also used in iTunes, even on non-Apple hardware.
INTEGER – It is an integer, stored in 1, 2, 3, 4, 6, or 8 bytes depending on the value. REAL – It is a floating point value, stored as an 8-byte floating number. TEXT – It is a string, stored using the database encoding (UTF).
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..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With