It has been twice now in a short period that one of my algorithms crashed because of rounding errors when using VB for my excel file. In performing simulation analysis I have to calculate the square root of a-b, where a and b can take any value on [0,1]. It can happen that both a and b are equal (in my case they will most likely be 1 then). The program throws an error since it calculates 1 - 1 = -1.2..*10^-16. The input was read from an excel sheet. Is there anything else I can do about this than simply using the round function with ten digits or so in every formula where i can't have negative numbers?

Same kind of problem surfaces with stopping criteria. I have to stop when for example a = b. But even when a = b in excel, VB might think it is smarter than that and will return a false when testing a = b. I currently check if the absolute difference is smaller than a very small number.

All these things make the code less clear to read and that is a very important aspect for me.

Hope you have some usefull tips for me.

Patrick