bitwise.carbon 827 B

123456789101112131415161718192021222324252627282930
  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. // RUN: %{explorer-run}
  7. // RUN: %{explorer-run-trace}
  8. // CHECK:STDOUT: result: 0
  9. package ExplorerTest api;
  10. fn Main() -> i32 {
  11. if (not (^0 == -1)) { return 11; }
  12. if (not (^1 == -2)) { return 12; }
  13. if (not (^(-3) == 2)) { return 13; }
  14. if (not (3 & 6 == 2)) { return 21; }
  15. if (not (-1 & 4 == 4)) { return 22; }
  16. if (not (-1 & -2 == -2)) { return 23; }
  17. if (not (1 | 4 == 5)) { return 31; }
  18. if (not (5 | 3 == 7)) { return 32; }
  19. if (not (-2 | 1 == -1)) { return 33; }
  20. if (not (1 ^ 4 == 5)) { return 41; }
  21. if (not (5 ^ 3 == 6)) { return 42; }
  22. if (not (-2 ^ -3 == 3)) { return 43; }
  23. return 0;
  24. }