Subject | Re: [IBO] Rounding problems |
---|---|
Author | Paul Hope |
Post date | 2001-08-08T07:26:20Z |
Lee
I have experimented with all sorts of rounding techniques for quite a while
and have only found 1 that is consistently correct - it is the RoundNear
function contained in the uRounding unit shipped with IBO source.
I use this in Delphi code and have modified the FreeUDFLib rounding function
of SQL stuff
Regards
Paul
""Leeway"" <lee@...> wrote in message
news:9ko7c3+kai0@......
I have experimented with all sorts of rounding techniques for quite a while
and have only found 1 that is consistently correct - it is the RoundNear
function contained in the uRounding unit shipped with IBO source.
I use this in Delphi code and have modified the FreeUDFLib rounding function
of SQL stuff
Regards
Paul
""Leeway"" <lee@...> wrote in message
news:9ko7c3+kai0@......
> I need to extract the VAT from a amount.
> I have four fields
> the fields are NUMERIC(18,2)
> EP_VAT (the amount of VAT)
> EP_INCL (the amount including VAT)
> EP_EXCL (the amount without the VAT)
> VAT (the percentage VAT)
>
> The example
> EP_INCL = 766.05
> VAT = 21.00
>
> begin
> //to calculate the amount VAT :
> // amount-including-vat divided by 100+vat% times vat%
> // (766.05 / (100 + 21.00)) * 21.00
> // (766.05 / 121) * 21.00 = 132.9508 this is correct
>
> QTIB_Art.FieldByName('EP_VAT').AsCurrency :=
> ((QTIB_Art.FieldByName('EP_INCL').AsCurrency / (QTIB_Art.FieldByName
> ('VAT').AsCurrency + 100)) * QTIB_Art.FieldByName('VAT').AsCurrency);
>
> //to calculate the amount exclusive VAT :
> // amount-including-vat divided by 100+vat% times 100
> // (766.05 / (100 + 21.00)) * 100
> // (766.05 / 121) * 100 = 633.0991 the fields are
> // numeric(18,2) so it rounds on two decimals and should give
> // 633.10 but it gives 633.09 what am I doing wrong ?
>
> QTIB_Art.FieldByName('EP_EXCL').AsCurrency :=
> ((QTIB_Art.FieldByName('EP_INCL').AsCurrency /(QTIB_Art.FieldByName
> ('VAT').AsCurrency + 100)) * 100);
>
> end
>
>
>
>
>
> Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
>
>
>