File: div_s32.c1 /* 2 * C:\Anitha\SVN\src\2010-GpcaMedicalDevice\Model\controller\slprj\grt\_sharedutils\div_s32.c 3 * 4 * Code generation for model "ALARM_Functional". 5 * 6 * Model version : 1.1326 7 * Simulink Coder version : 8.4 (R2013a) 13-Feb-2013 8 * C source code generated on : Thu Sep 12 09:49:37 2013 9 * Created for block: ALARM_Functional 10 */ 11 12 #include "rtwtypes.h" 13 #include "rtw_shared_utils.h" 14 15 int32_T div_s32(int32_T numerator, int32_T denominator) 16 { 17 int32_T quotient; 18 uint32_T tempAbsQuotient; 19 uint32_T quotientNeedsNegation; 20 if (denominator == 0) { 21 quotient = numerator >= 0 ? MAX_int32_T : MIN_int32_T; 22 23 /* Divide by zero handler */ 24 } else { 25 quotientNeedsNegation = (uint32_T)((numerator < 0) != (denominator < 0)); 26 tempAbsQuotient = (uint32_T)(numerator >= 0 ? numerator : -numerator) / 27 (denominator >= 0 ? denominator : -denominator); 28 quotient = quotientNeedsNegation ? -(int32_T)tempAbsQuotient : (int32_T) 29 tempAbsQuotient; 30 } 31 32 return quotient; 33 } 34 |