-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix comparing two unsigned types (#488)
- Loading branch information
Showing
3 changed files
with
24 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import "stdlib/io.jou" | ||
|
||
|
||
# TODO: It's not possible to test things like "signed < unsigned" yet with types of the same size. | ||
# For 8-bit there's only unsigned (byte), for 16-bit only signed (short), 32-bit only signed (int), 64-bit only signed (long). | ||
def main() -> int: | ||
a = 0 as byte | ||
b = 100 as byte | ||
c = 200 as byte | ||
|
||
printf("%d %d %d\n", a < b, b < b, c < b) # Output: 1 0 0 | ||
printf("%d %d %d\n", a > b, b > b, c > b) # Output: 0 0 1 | ||
|
||
printf("%d %d %d\n", a <= b, b <= b, c <= b) # Output: 1 1 0 | ||
printf("%d %d %d\n", a >= b, b >= b, c >= b) # Output: 0 1 1 | ||
|
||
printf("%d %d %d\n", a == b, b == b, c == b) # Output: 0 1 0 | ||
printf("%d %d %d\n", a != b, b != b, c != b) # Output: 1 0 1 | ||
|
||
return 0 |