Fixed integer printing for negative numbers.
This commit is contained in:
parent
e871378f8f
commit
7f426b5f25
@ -64,16 +64,17 @@ var parsedData = ['0','0','0','0','0','0','0','0','0','0']
|
||||
proc terminalWrite*(data: int) =
|
||||
var input = data
|
||||
var i = 0
|
||||
if(input < 0):
|
||||
terminalWrite('-')
|
||||
if(input == 0):
|
||||
terminalWrite('0')
|
||||
else:
|
||||
while(input > 0):
|
||||
let parsedChar: char = char(48 + (input mod 10))
|
||||
parsedData[i] = parsedChar
|
||||
i = i + 1
|
||||
input = input div 10
|
||||
return
|
||||
if(input < 0):
|
||||
terminalWrite('-')
|
||||
input = input * -1
|
||||
while(input != 0):
|
||||
let parsedChar: char = char(48 + (input mod 10))
|
||||
parsedData[i] = parsedChar
|
||||
i = i + 1
|
||||
input = input div 10
|
||||
while i > 0:
|
||||
i = i - 1
|
||||
terminalWrite(parsedData[i])
|
||||
|
@ -2,6 +2,8 @@ import tty
|
||||
|
||||
proc kernelMain() {.exportc: "kernel_main"}=
|
||||
terminalInitialize()
|
||||
terminalWrite("Hello World!\LNim here!\L")
|
||||
for i in 0..10:
|
||||
terminalWrite(i)
|
||||
terminalWrite("Hello World!\L")
|
||||
terminalWrite("MAX_INT:")
|
||||
terminalWrite(high(int))
|
||||
terminalWrite("\LMIN_INT:")
|
||||
terminalWrite(low(int32)+1)
|
||||
|
Loading…
Reference in New Issue
Block a user