mixedfloat.c 528 B

123456789101112131415161718192021222324252627282930313233
  1. #include <u.h>
  2. #include <lib9.h>
  3. #define INT 2
  4. #define FLOAT 2.5
  5. #define A 4 // addition result
  6. #define M 5 // multiplication result
  7. void
  8. main()
  9. {
  10. int a, b, x, y;
  11. float f;
  12. double d;
  13. f = FLOAT;
  14. d = FLOAT;
  15. a = b = x = y = INT;
  16. a += (double)d;
  17. b *= (double)d;
  18. x += (float)f;
  19. y *= (float)f;
  20. fprint(2, "[double] addition: %d; multiplication: %d\n", a, b);
  21. fprint(2, "[float] addition: %d; multiplication: %d\n", x, y);
  22. if(a != A || x != A || b != M || y != M)
  23. exits("FAIL");
  24. print("PASS\n");
  25. exits("PASS");
  26. }