I am working on a simple app where I need to use Shunting-yard algorithm. To make sure that everything works fine I want to create unit tests obviously. One case is driving me crazy. I mean when subtraction and checking if result of 15.5 - 15.1 from my algorithm is the same as 0.4. Test fails with an error: XCTAssertEqual failed: ("Optional(0.40000000000000036)") is not equal to ("Optional(0.4)").
Any ideas how to avoid this loss of bits?
Both algorithm and expression in test case are based on doubles.