Fixed printing of unsigned integers.

This commit is contained in:
neviyn 2017-11-06 21:43:34 +00:00
parent 367f7ab3b7
commit 4d896d0eb7

View File

@ -65,9 +65,9 @@ proc terminalWrite*(data: string) =
proc terminalWrite*(data: char) =
terminalWriteChar(data)
var parsedData = ['0','0','0','0','0','0','0','0','0','0']
var parsedData: array[0..9, char]
proc terminalWrite*(data: int) =
proc terminalWrite*(data: SomeSignedInt) =
if(data == 0):
terminalWrite('0')
return
@ -85,3 +85,17 @@ proc terminalWrite*(data: int) =
i = i - 1
terminalWrite(parsedData[i])
proc terminalWrite*(data: SomeUnsignedInt) =
if(data == 0):
terminalWrite('0')
return
var input = data
var i = 0
while(input != 0):
let parsedChar: char = char(48'u + (input mod 10))
parsedData[i] = parsedChar
i = i + 1
input = input div 10
while i > 0:
i = i - 1
terminalWrite(parsedData[i])