Show a specific number of decimal places in floating-point numbers in the Lua language

2

I started learning a little about the language Lua and I'm doing some algorithms to practice and one of them should show in the output of the floating point values with 4 decimal places. In C ++ I would use cout << fixed << setprecision(4); , I searched a lot and did not find a way in the Lua language.

    
asked by anonymous 08.08.2016 / 22:28

1 answer

2

Uses similar to printf() of language C:

string.format("%.4f", 25.33333333)

See running on ideone .

This page can help .

Basic Documentation .

    
08.08.2016 / 22:42