Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions stdlib/int.jk
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
func bin(i: int) -> string {
mut result = "";
mut i_copy = i;

while i_copy > 0 {
if i_copy % 2 == 0 {
result = concat("0", result);
} else {
result = concat("1", result);
}

i_copy = i_copy / 2;
}

// FIXME: We want proper 2's complement representation
if i < 0 {
concat("-", result)
} else {
result
}
}

func hex(i: int) -> string {
"0xff"
}
1 change: 1 addition & 0 deletions stdlib/lib.jk
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
incl pair
incl int
incl string
incl maybe
incl range
Expand Down