SQLite Forum

"Office Space"... I'm losing all those pennies
Login
I'm building a financial application and for some reason I'm losing pennies. I can remember the days when I wrote a lot of C code and had to give up using floating point because of the conversion(s). But I would expect different from a DB.

SAMPLE:

```
sqlite> select sum(cast('16.15' as numeric))*100;
1615.0
sqlite> select cast(sum(cast('16.15' as numeric))*100 as int);
1614
sqlite> select sum(cast(cast('16.15' as numeric)*100 as int));
1614
sqlite> select printf('%d', sum(cast('16.15' as numeric))*100);
1614
sqlite> select printf('%.0f', sum(cast('16.15' as numeric))*100);
1615
```