Important thing to note is that double and float numbers have to be compared with some accuracy, due to limitations of computers to represent numbers. In our case accuracy of 0.00001 is more than enough.