2024-07-30 20:02:55 +02:00

26 lines
334 B
Plaintext

import mem
import sys
number(x) {
length := 20
buffer := mem.alloc(length)
itoa(x, buffer, length)
mem.free(buffer, length)
}
itoa(x, buffer, length) {
end := buffer + length
tmp := end
digit := 0
loop {
x, digit = x / 10
tmp -= 1
tmp[0] = '0' + digit
if x == 0 {
sys.write(1, tmp, end - tmp)
return
}
}
}