I know UIKit
uses CGFloat
because of the resolution independent coordinate system.
But every time I want to check if for example fram
I am using the following comparison function to compare a number of decimal places:
bool compare(const double value1, const double value2, const int precision)
{
int64_t magnitude = static_cast(std::pow(10, precision));
int64_t intValue1 = static_cast(value1 * magnitude);
int64_t intValue2 = static_cast(value2 * magnitude);
return intValue1 == intValue2;
}
// Compare 9 decimal places:
if (compare(theView.frame.origin.x, 0, 9)) {
// do important operation
}