Simplified itoa
This commit is contained in:
@ -4,7 +4,8 @@ import sys
|
||||
number(x) {
|
||||
length := 20
|
||||
buffer := mem.alloc(length)
|
||||
itoa(x, buffer, length)
|
||||
tmp := itoa(x, buffer, length)
|
||||
sys.write(1, tmp, buffer + length - tmp)
|
||||
mem.free(buffer, length)
|
||||
}
|
||||
|
||||
@ -19,8 +20,7 @@ itoa(x, buffer, length) {
|
||||
tmp[0] = '0' + digit
|
||||
|
||||
if x == 0 {
|
||||
sys.write(1, tmp, end - tmp)
|
||||
return
|
||||
return tmp
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user