Way to round to only 1 decimal?
I need an easy way to round to only one decimal (0.1) in microscript 2?
I need an easy way to round to only one decimal (0.1) in microscript 2?
To round a to the nearest multiple of b, use round(a / b) * b. So, to round a to the nearest 0.1:
round(a * 10) / 10
Thanks!
If you need to round a number to a specific precision in order to display it on the screen or in the console as a text variable, you can use the number.toFixed(1) function.
  a = 123.456
  print( a.toFixed(1) )
how would I use one of these with screen.drawText?
init = function()
  number = 3.14159
end
update = function()
  screen.clear()
  screen.drawText(number.toFixed(1), 0, 0, 10, "white")
end
👍