bitwise.carbon 701 B

12345678910111213141516171819202122232425262728
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. //
  5. // AUTOUPDATE
  6. // CHECK:STDOUT: result: 0
  7. package ExplorerTest api;
  8. fn Main() -> i32 {
  9. if (^0 != -1) { return 11; }
  10. if (^1 != -2) { return 12; }
  11. if (^(-3) != 2) { return 13; }
  12. if (3 & 6 != 2) { return 21; }
  13. if (-1 & 4 != 4) { return 22; }
  14. if (-1 & -2 != -2) { return 23; }
  15. if (1 | 4 != 5) { return 31; }
  16. if (5 | 3 != 7) { return 32; }
  17. if (-2 | 1 != -1) { return 33; }
  18. if (1 ^ 4 != 5) { return 41; }
  19. if (5 ^ 3 != 6) { return 42; }
  20. if (-2 ^ -3 != 3) { return 43; }
  21. return 0;
  22. }