Skip to content
This repository was archived by the owner on Jan 14, 2018. It is now read-only.

Conversation

@fcanas
Copy link

@fcanas fcanas commented Jul 20, 2015

CGFloat is a float on 32-bit architectures and a double on 64-bit architectures. This makes the use of fabsf inappropriate on 64-bit arm. But changing the function to fabs would be inappropriate for 32-bit targets (making #434 incorrect).

I propose using the preprocessor macro ABS to avoid the problem altogether.

The reason for such a change is to help the use of this library on projects where strict static analysis is enforced.

A longer, more explicit architecture-dependent approach is also possible.

#if CGFLOAT_IS_DOUBLE
    CGFloat fullWidth = fabs(finalLeftEdge - initialLeftEdge);
#else
    CGFloat fullWidth = fabsf(finalLeftEdge - initialLeftEdge);
#endif

This may be preferable in cases where the distinct functions are known to have some advantage. However absolute value is a simple enough function that the macro's behavior will be identical.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant