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