> Thanks Sean and Simon :)

@Seam : The library seems interesting, but I would not use an external
library, as I use C as interface for Ada.

@Simon : Do you mean to store as integer or string whereas the Numeric
(x,y) column type exists, in order to have a nice binding in C ?
It's sure that I want to have sum() and others operations on the column and
the 'good' type if possible. I guess it is impossible to bind with string
type with a numeric column, maybe with bytes and void pointer
(sqlite3_bind_blob or other) ?
I am still looking for the best solution :)

Thanks


> 2011/12/19 Simon Slavin <slav...@bigfraud.org>
>
>>
>> On 19 Dec 2011, at 4:38pm, Alexandre K wrote:
>>
>> > I have a question about C binding for sqlite. I have seen those for
>> > integer, float... but I was wondering how to deal with a NUMERIC (x, y)
>> > type ?
>> > We can't use float or double, we could loose precision, so maybe with a
>> > string ?
>>
>> There are two standard ways to deal with fixed-precision numbers in
>> SQLite: bind them as integers or as strings.
>>
>> Storing as integers is useful if you see them as numbers you might want
>> to do maths on them.  For a column of prices in Euros, for example, you
>> would multiply all your numbers by a hundred, then store those as integers.
>>  So a value of 1 would mean one cent, and a value of 100 would mean one
>> euro.  Doing this means you can do things like sum(price) on a column and
>> SQLite could do the calculations quickly and with full precision.  Your
>> program (or a library it uses) must know to multiply or divide by 100 when
>> it stores or retrieves a value from that column.
>>
>> Storing as strings is useful if you are storing numbers you expect will
>> probably be used only for printing.  This saves time doing conversion, and
>> it means you definitely know where the decimal point went.  It also means
>> that length(price) is faster, which will also speed up printing.
>>
>> Simon.
>> _______________________________________________
>> sqlite-users mailing list
>> sqlite-users@sqlite.org
>> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>>
>
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to