3 ms·
'<' versus '<=' can be very important, and it can cause severe bugs when dealing with things like array indices or financial data. There are some cases where i
by nathan_f77 8y ago
'<' versus '<=' can be very important, and it can cause severe bugs when dealing with things like array indices or financial data.
There are some cases where it's not a big deal. '<' and '<=' can be interchangeable if one or both of the values are a rough estimate. One example would be comparing two images and doing something if they are a close match. It might not be too bad if you use `<= 0.995` instead of `< 0.995` when checking the percentage.
Some other examples might involve accelerometer data, pressure sensors, GPS boundaries, debounce algorithms, animations, etc. But I think it's just a good habit to write test cases that test those boundary values.
- progval 8y agoBasically, it depends on whether we're dealing with floats or integers.