Subject Re: [firebird-support] Multiplication and Data Types
Author Martijn Tonies
Hi,

> Is there anyone that could give me a detailed explanation on
> multiplication of different data types. data type of result of this
> operation is not very clear to me.
>
> Another problem that i need solution for is:
>
> I have a table with items, prices and quanities. Multiplication of
> last two and summing gives me a amount od sold items. At the end of
> the day i am decreasing my stock by summing all quantities grouped by
> items and put that in a different table for stock tracking. The
> problem is that multiplication of prices(same as in the first table)
> and quantities gives me different amount then in the first case.

Define "different"? Rounding errors?

> How to solve this (which data type, precission etc.)

In these cases, I suggest using fixed-point datatypes, not floating
point.

This would be: NUMERIC(18, 2) or NUMERIC(18, 4) for
example.

Martijn Tonies
Database Workbench - development tool for Firebird and more!
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com