Strange problem with double conversion.


Im using visual studio 2010, windows form.

I have this code, that permit to convert money from USD to EUR. This is reference:

This is code:

CurrencyConverter2 cc = new CurrencyConverter2();
cc.AdjustToLocalTime = true;

CurrencyData cd = new CurrencyData("USD", "EUR");
// Convert US Dollars to Euros

cc.GetCurrencyData(ref cd);

label5.Text = (5000 / cd.Rate).ToString();

OUTPUT IN THIS CASE IS : 3753,75375375375

But if I place value (example 5000) from texbox in this way:

double cambiamo = double.Parse(tbxDaConvertire.Text);
tbxConvertito.Text = (cambiamo * cd.Rate).ToString();

OUTPUT IS: 3752,5

I dont understand because Im getting this value! How can I solve it please?

Your first conversion used a conversion rate of 0.75075

Your second conversion used a conversion rate of 0.75050

Just a 0.00025 difference, easily found back in this chart of the conversion rate of the past week:

Note the extreme volatility, the rate changes in minutes. Or to put it another way, it changed while you edited your code. Clearly you are getting live updates from your currency conversion service.