## Minus Calculation problems

### Minus Calculation problems

This is in reply to the rounding problem I had, but Ive now realised its not
a rounding error - its a minus error!

Heres what happens.

When I work out vat at 17.5% on a figure, say 39.00, it comes to 6.83
This is correct.  But now I need to minus the vat from my subtotal, say

1561.00
6.83 -
-------
1554.17

But I get 1554.18 - 1 penny out every time.

But, when I add the VAT (I just did this as a test, it adds the VAT
perfectly (1561.00 + 6.83) = 1567.83

All my fields are calculated currency fields.

Does anyone know what I am doing wrong..

Would appreciate any help!

Thanks

### Minus Calculation problems

How are you calculating the value (sorry I missed any early posts you made)?
Are you using floats?   What are you doing with the result of the
calculation to get your final numbers?  It sounds like your rounding error
is now just happening on the result of the subtraction, but it is still
rounding error.  TCurrencyFields are just glorified TFloatFields so they
work exactly like doubles when you do arithmetic with them.

39.0 * 0.175 isn't really 6.83 its 6.825.
1561.0 - 6.83 is 1554.17 but 1561.0 - 6.825 is 1554.175.
Depending on how you arrive at your final value it is entirely possible that
1554.175 becomes 1554.18 since TCurrentField just uses a call to FloatToStrF
to display the value so it is essentially going like this
FloatToStrF(1561.00 - (39.0 * 0.175), ffCurrency, 12,2);  ====> \$1,554.18

Hope that helps.  Sorry again if I missed some stuff from earlier postings.

Respectfully yours,
graham

Quote:>This is in reply to the rounding problem I had, but Ive now realised its
not
>a rounding error - its a minus error!

>Heres what happens.

>When I work out vat at 17.5% on a figure, say 39.00, it comes to 6.83
>This is correct.  But now I need to minus the vat from my subtotal, say

> 1561.00
>    6.83 -
> -------
> 1554.17

>But I get 1554.18 - 1 penny out every time.

>But, when I add the VAT (I just did this as a test, it adds the VAT
>perfectly (1561.00 + 6.83) = 1567.83

>All my fields are calculated currency fields.

>Does anyone know what I am doing wrong..

>Would appreciate any help!

>Thanks

Hi,

I have the following statement:

SqlStg = "UPDATE dbo.tblProject"
SqlStg = SqlStg & " SET Pr_ExecMeeting# = " & Me.EC_Number & ", Pr_ExecDate
= " & Me.ECDate & " WHERE " & vCriteria

Me.ECDate refers to an unbound field on the form with a default value set to
Date().

When I execute the statement, the Pr_ExecDate always returns 12:00AM.
Am I missing something?

SF