This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
TheArchitect's profile picture

Displaying decimal point

Started by TheArchitect, 01 April 2013 - 06:01 PM
TheArchitect #1
Posted 01 April 2013 - 08:01 PM
I have a program that stores a number in a file for later display. The text file contains only this number.

When the program reads the number and displays it on screen, it displays just fine - i.e 54. But if I send the exact same variable to a printer, it gets displayed as 54.0. I have tried to tostring() it and math.floor() it, but it displays exactly the same.

Is there a way to configure a display/printout to use only the integer part of a number? It's odd to see a decimal point in uses where only integers make sense.
JokerRH #2
Posted 02 April 2013 - 05:04 AM
I have tried to tostring() it and math.floor() it, but it displays exactly the same.

?


lua> term.write(54)
--> 54.0
lua> term.write(tostring(54))
--> 54
remiX #3
Posted 02 April 2013 - 05:50 AM
I have tried to tostring() it and math.floor() it, but it displays exactly the same.

?


lua> term.write(54)
--> 54.0
lua> term.write(tostring(54))
--> 54

He's talking about printing the text using a printer …
theoriginalbit #4
Posted 02 April 2013 - 05:54 AM
He's talking about printing the text using a printer …
term.write
monitorObj.write
printerObj.write

all function in the same way… this is why he posted that…
TheArchitect #5
Posted 02 April 2013 - 11:07 AM
… I'll have to admit my mistake. I must have done something wrong before, because I tried it again and tostring() did it.

Sorry about that. And thanks for taking a moment to still reply :)/>