Advertisement
Guest User

Untitled

a guest
May 27th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. #include <time.h>
  4.  
  5. #define FLOATING
  6.  
  7. int main() {
  8. int x;
  9. #ifdef FLOATING
  10. float z = 1;
  11. #else
  12. short z = 1;
  13. #endif
  14. struct timespec begin,end;
  15. clock_gettime(CLOCK_REALTIME,&begin);
  16. for(x=0; x!=1000000000; x++) {
  17. #ifdef FLOATING
  18. z /= 0.00447467;
  19. #else
  20. z /= 5000;
  21. #endif
  22. }
  23. clock_gettime(CLOCK_REALTIME,&end);
  24. printf(
  25. #ifdef FLOATING
  26. "Floating point:"
  27. #else
  28. "Fixed point:"
  29. #endif
  30. "\n"
  31. );
  32. printf("TIME: %lu, z=%f\n", end.tv_nsec-begin.tv_nsec, (double)z);
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement