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

Scientific Notation on Monitors

Started by Fyrecean, 20 August 2014 - 04:22 AM
Fyrecean #1
Posted 20 August 2014 - 06:22 AM
So i was trying to make a computer display the RF in a resonant energy cell on a monitor, but the energy is displayed in scientific notation instead of regular numbers, and i cant find a way to stop it.
the code says:

c = peripheral.wrap("bottom')
m = peripheral.wrap("right")
m.clear()
while true do
en = c.getEnergyStored("bottom")
m.setCursorPos(1,2)
m.setTextColor(512)
m.write("Energy:")
m.setCursorPos(8,2)
m.setTextColor(8192)
m.write(en)
print(en)
sleep(5)
end

on the monitor its scientific notation on the computer itself, its in in regular numbers
Thanks in advance

PS I'm not a programmer i've just been combing several forum posts and youtube tutorials until i could find all the lines i needed to make this program,
Bomb Bloke #2
Posted 20 August 2014 - 10:04 AM
If memory serves - and I could be wrong - tostring should sort this out for you:

m.write(tostring(en))
Yevano #3
Posted 20 August 2014 - 12:03 PM
tostring unfortunately still does formatting with big E notation I think. Try messing around with string.format and %f. http://lua-users.org/wiki/StringsTutorial
Fyrecean #4
Posted 21 August 2014 - 03:29 AM
tostring did work, thanks both of you