@naitik, Your question is answered above. If b = 100 and a = 100, You are allowing the transaction to happen. And the resulting balance is b-a-0.5 = -0.5. And of course you cannot have negative balance. So, I guess you should figure it out where you are doing it wrong.
P.S: Pleas learn how to post a question. And also how to provide a code snippet. Use the Code Sample formatting tool in the editor while typing the question. (Or select the code and press Ctrl + K).