Coercion

Lua provides automatic conversion between string and number values at run time. Any arithmetic operation applied to a string tries to convert this string to a number, following the usual conversion rules. Conversely, whenever a number is used where a string is expected, the number is converted to a string, in a reasonable format. For complete control over how numbers are converted to strings, use the format function from the string library.

Note that coercion only applies to arithmetic operations and does not apply to comparison operations. Any comparison between two variables of different types will always return false (see Relational Operators).