Subject Re: [firebird-support] Numeric(18,4) calculations
Author jengleman@formaleasy.com
I have been using Interbase and now Firebird for the last 7 years. I
have been using Numeric(15,2).
The only problem I have is that the any tax calculations done must be
rounded off. I do most calculations
in Delphi and not on Firebird because of the application is point of
sale and it is easier to control when
to add tax and when not to use tax. The RoundDollar routine I have in
Delphi is:

function RoundDollar(xc: Currency): Currency;
begin
Result := xc*100;
Result := Round(Result);
Result := Result / 100;
end;

and this seems to work for to Round off all of the currency calculations
that I use before storing in the database.

I hope this helps

Jack Engleman


t.s. wrote:
> >> both "qty" and "unit_price" is numeric(18,4).
> >>
> >> From my testing, the 'limit' seems to be around 11-12 digits.
> > There is nothing to wonder at: multiplying numeric(18,4) by
> > numeric(18,4) you are getting numeric(19,8).
> Understood. But is there a way to do the calculation ANYWAY since the
> resulting number *should* fit in numeric(18,4) ? Using numeric(18,4) as
> 'currency' data type pretty much dictates that at some point it will be
> used in such calculations.
>
> Unless you're saying that we should not use numeric(18,4) as a currency
> data type at all... If that's the case, then what do you suggest we use
> for this purpose?
>
> Thanks in advance,
> regards,
> t.s.
>
>
>
>
>
>
>
>
>
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
> Visit http://firebird.sourceforge.net and click the Resources item
> on the main (top) menu. Try Knowledgebase and FAQ links !
>
> Also search the knowledgebases at http://www.ibphoenix.com
>
> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>
>
>
> ------------------------------------------------------------------------
> YAHOO! GROUPS LINKS
>
> * Visit your group "firebird-support
> <http://groups.yahoo.com/group/firebird-support>" on the web.
>
> * To unsubscribe from this group, send an email to:
> firebird-support-unsubscribe@yahoogroups.com
> <mailto:firebird-support-unsubscribe@yahoogroups.com?subject=Unsubscribe>
>
> * Your use of Yahoo! Groups is subject to the Yahoo! Terms of
> Service <http://docs.yahoo.com/info/terms/>.
>
>
> ------------------------------------------------------------------------
>