You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
962B

  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <stdint.h>
  4. #include <string.h>
  5. #include <math.h>
  6. #include <algorithm>
  7. #include "util/math.hpp" // Rack
  8. #include "dsp/fixed.hpp"
  9. using namespace bogaudio::dsp;
  10. int main() {
  11. {
  12. fixed_16_16 x = 5;
  13. fixed_16_16 y = 1;
  14. x = 3;
  15. printf("X=%d\n", (int)(x + y));
  16. y = 2;
  17. printf("X=%d\n", (int)(x - y));
  18. x = y + 5;
  19. printf("X=%d\n", (int)x);
  20. x = y - 3;
  21. printf("X=%d\n", (int)x);
  22. x += 2.5;
  23. printf("X=%d\n", (int)x);
  24. printf("X=%f\n", (float)x);
  25. x = y - 0.3;
  26. printf("X=%d\n", (int)x);
  27. printf("X=%f\n", (float)x);
  28. }
  29. {
  30. fixed_32_32 x = 5;
  31. fixed_32_32 y = 1;
  32. x = 3;
  33. printf("X=%d\n", (int)(x + y));
  34. y = 2;
  35. printf("X=%d\n", (int)(x - y));
  36. x = y + 5;
  37. printf("X=%d\n", (int)x);
  38. x = y - 3;
  39. printf("X=%d\n", (int)x);
  40. x += 2.5;
  41. printf("X=%d\n", (int)x);
  42. printf("X=%f\n", (float)x);
  43. x = y - 0.3;
  44. printf("X=%d\n", (int)x);
  45. printf("X=%f\n", (float)x);
  46. }
  47. return 0;
  48. }