After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 106332 - bad aproximations in exchange rate
bad aproximations in exchange rate
Status: VERIFIED FIXED
Product: GnuCash
Classification: Other
Component: Engine
1.8.x
Other other
: Normal normal
: ---
Assigned To: Derek Atkins
Derek Atkins
Depends on:
Blocks:
 
 
Reported: 2003-02-17 17:51 UTC by Paolo Benvenuto
Modified: 2018-06-29 20:28 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Paolo Benvenuto 2003-02-17 17:51:53 UTC
I made a currency exchange in my bank, converting US$ 4,000.00 from my US$
bank account into exactly RD$ 71,640.00 (exchange rate of exactly 17.91
RD$/US$), which went automatically to my RD$ bank account.

However, when I enter the  transaction, gnucash makes an approximation in
the exhcange rate, so that if I fix the RD$ value to 71,640.00, the
corresponding US$ value is constantly 3,999.66, which _isn't_ the amount I
caught from my US$ account.

Inversely, if I fix the US$ part of the transaction to US$ 4,000.00, then
the corresponding RD$ value changes to RD$ 71.646,07, which _isn't_ the
amount I got in my RD$ account.

If I fix the exchange rate to 17.91, neither that way I get the correct US$
and RD$ values.

It seems like *there isn't* a way to get both currency values exactly what
is entered.

This way, gnucash either gets a mistake in the US$ or in the RD$ bank account.
Comment 1 Derek Atkins 2003-02-18 00:40:57 UTC
I see the problem, but I'm not really sure what do about it.  If you
make the entry from the US$ side it works just fine.  However if you
make it from the other side, it does not.  The problem is that in one
direction it's trying to store 17.91.  In the other it's trying to
store 1/17.91 == .05583472920156337241 -- so yes, it is losing precision.

Obviously I can store this as 100/1791 and it should work fine.

Thank you for the report.  I'll see how quickly I can fix this.
Comment 2 Derek Atkins 2003-02-18 06:20:46 UTC
This is fixed in CVS, and will be in 1.8.2

Thank you for the report.
Comment 3 Paolo Benvenuto 2003-02-23 15:57:51 UTC
How did you fix it? doesn't it make aproximations any more?

In particular, I think it is important that when the "to amount" is
entered directly, it should be changed unless the exchange rate is
changed.

Thank you!
Comment 4 Derek Atkins 2003-02-23 16:10:04 UTC
No, it does not make approximations any more.
Comment 5 Derek Atkins 2003-02-23 16:10:31 UTC
If it did, I wouldn't have closed the bug!   Duh!
Comment 6 Paolo Benvenuto 2003-03-27 19:22:15 UTC
It still works bad.

In a new file, create a USD and a DOP account.

In the DOP register, transfer USD 3,375 from the USD account at
exchange rate of 1 USD = 24,20 DOP. If you want to have USD 3,3,75,
there's an aproximation in the exchange rate, namely 1 DOP = 0,041320.

If you go in the USD account register, all, is ok, but the
aproximation of the exchange rate is different: 1 DOP = 0,041322

I was having aproximation problems in more complex situations, without
understanding what was happening.

I think this simple case could help fixing.

Thank you!
Comment 7 Derek Atkins 2003-03-27 19:35:49 UTC
1) From the DOP register you have to enter values as DOP.
2) USD accounts can generally only old 2 significant digits unless you
   have specifically reconfigured it to do otherwise.

When I enter 3.375 in the USD account, it gets rounded to 3.38, which
is correct behavior.

So, perhaps you're hitting real-value rounding errors?  I cannot
reproduce your example as given, so I am re-closing this bug (because
I still think it is fixed).
Comment 8 Paolo Benvenuto 2003-03-28 01:32:33 UTC
Soory, the USD amount wasn't 3.375, but 3375 (threethousands etc.).

The problem isn't in the amount in one or the other currency, but in
the aproximation of the exchange rate.

Try this: a transaction from DOP 57761.29 to USD 3667.38 (a real
transaction in my datas between two bank accounts): it isn't possible
to have these two amounts, because of the aproximations.

If I insist in the DOP 57761.29, than I have USD 3667.38

Inversely, if I put USD 3667.38, I have a DOP 57762,71 !!!!

Maybe the problem could be resolved using a bigger number of digits in
the exchange rate (a long float instead of a float?).

Thank you for your attention.
Comment 9 Derek Atkins 2003-03-28 02:15:50 UTC
Works fine for me.

- Open up the DOP Account
- Tab to description
- type "test"
- tab to transfer
- type USD (the name of my USD account)
- tab to withdrawal
- type 57761.29
- hit "return"
- click on To Amount
- type "3667.38"
- hit return

I now have 57761.29 in the DOP account, and 3667.38 in the USD
account.  So, I don't know what your problem is.  I tested in both CVS
HEAD and CVS 1.8, and 1.8.2, and it works in all three versions.  Have
you not upgraded to 1.8.2?

If you have other problems, please open a new bug report.
Comment 10 Paolo Benvenuto 2003-03-30 18:52:38 UTC
Well, try this:

You withdraw USD 16,000 fom your bank account, change them at exactly
1 USD = 15,8 DOP, obtain exactly DOP 252,800, and put it, partly (DOP
150,000) to your DOP bank account, and partly (DOP 102,800) to your cash.

- open USD account
- Tab to description
- type "test"
- tab to transfer
- type DOP (the name of my DOP bank account)
- tab to withdrawal
- type 16000
- hit "return" (opens exchange rate dialog)
- click on To Amount
- type "252800"
- hit return

I have my DOP 252,800 in ,y bank account. But the money doesn't go all
to the bank, DOP must be to my cash:

- open DOP account
- activate split view
- change the DOP amount from 252,800 to 150,000
- hit down arrow ---> the 150,000 changed to 149,9999, and the 252,800
changed to 252,800.01!!!!
- put a second DOP account (for example dop1) in the new split: now it
impossible to set the exchange rate to exactly 15,8 DOP/USD, because
the thing is inverse: I must put exchange rate = "1 / 15,8", which is
being aproximated to 0,06329.

To have the exchange rate correct I must switch back to the usd
account, activate the split view and set the dop1 exchange rate to 15.8.

But whatever I could do, if I need a exact 15.8 echange rate, there
isn't a way to have the amount exact all together: USD = 16,000, DOP =
150,000, DOP1 = 102,800.

Thank you for your attention!
Comment 11 Paolo Benvenuto 2003-03-30 19:04:29 UTC
Besides that, I noted that anyway the exchange rate of the dop1 (or
dop? one of the two) split cannot be set to 15.8: every time I set to
that, it goes back to 15.80028 !

Inversely, from any of the DOP accounts, the exchange rate corresponds
permanently to 15.800284 !

I don't reopen the bug, as you told me, but it seems worth that!
Comment 12 Derek Atkins 2003-05-27 17:20:56 UTC
Hi.

If you create the txn from the DOP side it works just fine.

- open DOP account
- tab to description, enter "test"
- tab to transfer, enter "USD Account"
- click on the "Split" button to open split mode.
- go to the USD Account line, tab to withdrawal column, and enter 252800
- click on the DOP deposit cell
- in the Exchange Dialog, click 'to amount', enter 16000, and hit return
- type 150000 into the deposit cell, then hit return
- tab to the account column and enter your DOP Cash account for the
remaining 102800

So, it does work, if you enter it from the DOP side.
Comment 13 John Ralls 2018-06-29 20:28:45 UTC
GnuCash bug tracking has moved to a new Bugzilla host. This bug has been copied to https://bugs.gnucash.org/show_bug.cgi?id=106332. Please update any external references or bookmarks.