Fixed printing of unsigned integers.
This commit is contained in:
parent
367f7ab3b7
commit
4d896d0eb7
@ -65,9 +65,9 @@ proc terminalWrite*(data: string) =
|
|||||||
proc terminalWrite*(data: char) =
|
proc terminalWrite*(data: char) =
|
||||||
terminalWriteChar(data)
|
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):
|
if(data == 0):
|
||||||
terminalWrite('0')
|
terminalWrite('0')
|
||||||
return
|
return
|
||||||
@ -85,3 +85,17 @@ proc terminalWrite*(data: int) =
|
|||||||
i = i - 1
|
i = i - 1
|
||||||
terminalWrite(parsedData[i])
|
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])
|
||||||
|
Loading…
Reference in New Issue
Block a user