math.round

Has anyone noticed any problems with this?

I’ve been trying to use it (using Sublime Text2) and when I type math.round(x) it’s not turning blue to indicate it’s a reserved term.

Alex

i don’t use sublime, but i suspect it’s just not a word it recognizes for highlighting.  does sublime allow you to customize those rules yourself?

strictly speaking, “round” is not a reserved word, just a library function (and a custom one at that - it’s not part of the standard lua 5.1.5 math library), so perhaps not that surprising that it’s not highlighted.

Hi. Could you please post your code here so we can discuss it?

local fatigueReductionAverage = 1000/stillLivingUnits

math.round(fatigueReductionAverage)

In sublime Text2, ‘math.round’ isn’t appearing blue like it does for say math.random.

I printed out to console just to check, and he variable isn’t being rounded down/up

math.round definitely works under normal circumstances. Are you sure you haven’t overridden the function elsewhere in your code?

techie why:  that’s a “do-nothing” statement, without side-effects, since lua doesn’t “pass by reference” (google if curious)

practical solution:  you must explicitly assign the returned value if you wish to preserve the rounded result:

fatigueReductionAverage = math.round(fatigueReductionAverage)

i don’t use sublime, but i suspect it’s just not a word it recognizes for highlighting.  does sublime allow you to customize those rules yourself?

strictly speaking, “round” is not a reserved word, just a library function (and a custom one at that - it’s not part of the standard lua 5.1.5 math library), so perhaps not that surprising that it’s not highlighted.

Hi. Could you please post your code here so we can discuss it?

local fatigueReductionAverage = 1000/stillLivingUnits

math.round(fatigueReductionAverage)

In sublime Text2, ‘math.round’ isn’t appearing blue like it does for say math.random.

I printed out to console just to check, and he variable isn’t being rounded down/up

math.round definitely works under normal circumstances. Are you sure you haven’t overridden the function elsewhere in your code?

techie why:  that’s a “do-nothing” statement, without side-effects, since lua doesn’t “pass by reference” (google if curious)

practical solution:  you must explicitly assign the returned value if you wish to preserve the rounded result:

fatigueReductionAverage = math.round(fatigueReductionAverage)