Fixed integer printing for negative numbers.

This commit is contained in:
neviyn 2017-10-22 00:44:01 +01:00
parent e871378f8f
commit 7f426b5f25
2 changed files with 14 additions and 11 deletions

View File

@ -64,12 +64,13 @@ 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):
terminalWrite('-')
input = input * -1
while(input != 0):
let parsedChar: char = char(48 + (input mod 10)) let parsedChar: char = char(48 + (input mod 10))
parsedData[i] = parsedChar parsedData[i] = parsedChar
i = i + 1 i = i + 1

View File

@ -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)