If you really want to assert the equality (in some weak sense) of objects by using their string representation, then I would use scientific notation for floats and use a fixed precision to prevent problems with numerical instability.