MISRA Discussion Forums

Full Version: Casting a Float to a Signed Integer
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I'm working with some legacy code and part of my job is to modify it to comply with the MISRA standard. A large portion of the code relies on macros such as this one:

[code]#define CURRENT_LARGE_SHIFT (18L)
#define CURRENT_LARGE_SCALE(v) (int32_t)(v * (1L
The use of macros which are evaluated with multiple types is to be discouraged.

We do not see an easy solution and cannot provide specific advice.

Generally, we would suggest that the macro is replaced with a solution for each specific type.