I want a script that rounds any give number to hundredth. e.g. the number 1462345.723657812375 would be rounded to 1462345.72
Thanks in Advance [import]uid: 130035 topic_id: 28187 reply_id: 328187[/import]
I want a script that rounds any give number to hundredth. e.g. the number 1462345.723657812375 would be rounded to 1462345.72
Thanks in Advance [import]uid: 130035 topic_id: 28187 reply_id: 328187[/import]
Give this a go;
[lua]value = 100.1234567
local roundedValue = math.floor(value * 100 + 0.5) / 100
print (roundedValue)[/lua]
That should do it.
Peach
[import]uid: 52491 topic_id: 28187 reply_id: 113899[/import]
There is a math.round() already…
[lua]value = 100.1234567
local roundedValue = math.round( value * 100 ) / 100
print (roundedValue)[/lua]
http://docs.coronalabs.com/api/library/math/round.html [import]uid: 8271 topic_id: 28187 reply_id: 113900[/import]
Thanks both scripts work. For some reason I didn’t think of that yesterday. [import]uid: 130035 topic_id: 28187 reply_id: 113904[/import]