Next: 4.3 Adjustment Up: 4 The Language Previous: 4.1 Lexical Conventions

4.2 Coercion

Lua provides some automatic conversions. Any arithmetic operation applied to a string tries to convert that string to a number, following the usual rules. Conversely, whenever a number is used when a string is expected, that number is converted to a string, according to the following rule: if the number is an integer, it is written without exponent or decimal point; otherwise, it is formatted following the ``%g'' conversion specification of the standard printf C function.

Next: 4.3 Adjustment Up: 4 The Language Previous: 4.1 Lexical Conventions