div_repeat_s16s32_floor.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /*
  2. * File: div_repeat_s16s32_floor.c
  3. *
  4. * Code generated for Simulink model 'SOC'.
  5. *
  6. * Model version : 1.15
  7. * Simulink Coder version : 9.4 (R2020b) 29-Jul-2020
  8. * C/C++ source code generated on : Wed Aug 11 09:45:09 2021
  9. */
  10. #include "rtwtypes.h"
  11. #include "div_nzp_repeat_u32.h"
  12. #include "div_nzp_repeat_u32_ceiling.h"
  13. #include "div_repeat_s16s32_floor.h"
  14. int16_T div_repeat_s16s32_floor(int32_T numerator, int32_T denominator, uint32_T
  15. nRepeatSub)
  16. {
  17. uint32_T absDenominator;
  18. uint32_T absNumerator;
  19. int16_T quotient;
  20. if (denominator == 0) {
  21. quotient = (int16_T)(numerator >= 0 ? 32767 : -32768);
  22. /* Divide by zero handler */
  23. } else {
  24. absNumerator = numerator < 0 ? ~(uint32_T)numerator + 1U : (uint32_T)
  25. numerator;
  26. absDenominator = denominator < 0 ? ~(uint32_T)denominator + 1U : (uint32_T)
  27. denominator;
  28. if ((numerator < 0) != (denominator < 0)) {
  29. quotient = (int16_T)-(int32_T)div_nzp_repeat_u32_ceiling(absNumerator,
  30. absDenominator, nRepeatSub);
  31. } else {
  32. quotient = (int16_T)div_nzp_repeat_u32(absNumerator, absDenominator,
  33. nRepeatSub);
  34. }
  35. }
  36. return quotient;
  37. }
  38. /*
  39. * File trailer for generated code.
  40. *
  41. * [EOF]
  42. */