#include typedef float float32_t; void example ( void ) { /* ----------------- Example code from MISRA C:2012 begin ----------------- */ uint32_t counter = 0u; for ( float32_t f = 0.0f; f < 1.0f; f += 0.001f ) /* Non-compliant */ { ++counter; } float32_t f; for ( counter = 0u; counter < 1000u; ++counter ) /* Compliant */ { f = ( float32_t ) counter * 0.001f; } f = 0.0f; while ( f < 1.0f ) /* Non-compliant */ { f += 0.001f; } uint32_t u32a; f = read_float32 ( ); do { u32a = read_u32 ( ); } while ( ( ( float32_t ) u32a - f ) > 10.0f ); /* Compliant */ /* ------------------ Example code from MISRA C:2012 end ------------------ */ }