Advertisement
Guest User

div

a guest
Jan 17th, 2020
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.74 KB | None | 0 0
  1. /*
  2. ** EPITECH PROJECT, 2018
  3. ** secondEx
  4. ** File description:
  5. ** secondEx
  6. */
  7.  
  8. #include <stdio.h>
  9. #include <stdlib.h>
  10. #include "castmania.h"
  11.  
  12. int integer_div(int a, int b)
  13. {
  14.     return (b ? a / b : 0);
  15. }
  16.  
  17. float decimale_div(int a, int b)
  18. {
  19.     return (b ? (float)a / (float)b : 0);
  20. }
  21.  
  22. void exec_div(division_t *operation)
  23. {
  24.     if (!operation->div_type) {
  25.         ((integer_op_t *)operation->div_op)->res = integer_div((\
  26.             (integer_op_t *)operation->div_op)->a, \
  27.             ((integer_op_t *)operation->div_op)->b);
  28.     } else {
  29.         ((decimale_op_t *)operation->div_op)->res = decimale_div((\
  30.             (decimale_op_t *)operation->div_op)->a, \
  31.             ((decimale_op_t *)operation->div_op)->b);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement