Thanks,
Vipul
The exchange rate is not set with math and variables. It is agreed to by those that are exchanging, just like haggling over a price for produce or products in a market would happen. Some people have dollars (or other local currencies) and want bitcoins. Other people have bitcoins and want local currency. When they find each other, they either come to an agreement on how much they will exchange, or they fail to come to an agreement and they look for someone else to exchange with. Here's an example I wrote up previously:
Exchanges provide a place for people who want to buy bitcoins and people who want to sell bitcoins to find each other.
Example:
Albert has 100 BTC. He needs to pay his electric bill and the electric company doesn't accept bitcoin as payment. He decides to convert some of his bitcoin to USD. Albert logs on to an exchange and creates a limit order offering to sell 10 of his bitcoin for $33.45 each. He is not willing to sell the bitcoin for less than $33.45 because at any price less than that he'd rather just hold on to the bitcoin and pay his electric bill with other funds.
Bobby only has a two bitcoin that he purchased at $32.50 each. He decides that he doesn't really want bitcoin anymore, but he doesn't want to take loss. He logs on to the exchange and creates a limit order offering to sell his two bitcoin for $32.55 each.
Carl has just received his paycheck. After paying his expenses he has $200 left over. He decides to purchase bitcoin with this money. He feels like the exchange rate might drop a bit and so to get them as cheap as possible, he transfers his money to the exchange and creates a limit order to purchase 6.25 BTC at $32 each.
David just received an inheritance of $10,000. He decides he'd like to hold the entire balance as bitcoin. He has seen the exchange rate varying between $31.50 and $33.50 lately, and hopes he can get the entire balance at $31.50. He creates a limit order at the exchange for 317.460317 BTC at $31.50 each.
Earl is in a hurry. He just wants to buy something from Overstock.com right now, and he'll take whatever the current exchange rate is. He needs $60 worth of bitcoin. He transfers his $60 to the exchange and places a market order for $60 worth of bitcoin. The exchange sees that the cheapest offer to sell bitcoin at their site at the moment is Bobby's offer of 2 bitcoin at $32.55 each. The exchange transfers the $60 from Earl to Bobby and at the same time transfers 1.84331797 bitcoin from Bobby to Earl.
At this hypothetical moment the current bitcoin price is therefore $32.55, since that is the most recent exchange that has occurred.
Earl now has 1.84331797 BTC
Bobby now has $60 and 0.15668203 BTC still available to purchase at an exchange rate of $32.55 per bitcoin.
Now Albert suddenly realizes that he doesn't have enough other funds for his bill. He needs $334.50 right away to pay the bill, and needs to sell the bitcoin quickly to get the necessary money. Albert cancels his limit order and places a market order to sell $334.50 worth of bitcoin. The exchange sees that the most expensive offer to buy bitcoin at their site at the moment is Carl's offer of 6.25 bitcoin at $32 each. The exchange transfers $200 from Carl to Albert, and 6.25 bitcoin from Albert to Carl. Since Albert still needs another $134.50 worth of bitcoin to fulfill his order, the exchange sees that the next highest offer is David's offer of 317.460317 BTC at $31.50 each. The exchange transfers 4.26984127 BTC from Albert to David, and $134.50 from David to Albert.
At this hypothetical moment the current bitcoin price is therefore $31.50, since that is the most recent exchange that has occurred.
Albert now has the $334.50 that he needs, and still has 89.4801587 BTC remaining.
Carl has picked up the 6.25 bitcoin that he wanted, spending the $200 that he wanted to spend.
David has purchased 4.26984127 for $134.50, and still has a limit order out there waiting to be filled for another 313.190467 bitcoin at $31.50 each.
You'll notice that there are actually many "prices" for bitcoin. There is the price that each individual is willing to buy or sell their bitcoin for. Some of the more often quoted prices are the "current Ask", "current Bid" and "most recent exchange".
Prior to Earl coming along, the "Current Ask" was Bobby's $32.55 that he is asking to sell his bitcoin (the lowest price anyone is willing to sell for at that time).
The "Current Bid" was Carl's $32 bid to purchase bitcoin from anyone willing to sell that cheap (the highest anyone is willing to pay to buy at that time).