Simplified itoa
This commit is contained in:
parent
87ae78c86a
commit
76c916018a
@ -6,6 +6,7 @@ A simple programming language.
|
||||
|
||||
* Fast compilation
|
||||
* Small binaries
|
||||
* High performance
|
||||
|
||||
## Installation
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user