Logic Machine Forum
String format - Printable Version

+- Logic Machine Forum (https://forum.logicmachine.net)
+-- Forum: LogicMachine eco-system (https://forum.logicmachine.net/forumdisplay.php?fid=1)
+--- Forum: Scripting (https://forum.logicmachine.net/forumdisplay.php?fid=8)
+--- Thread: String format (/showthread.php?tid=3713)



String format - sashhun - 29.11.2021

Hello. Help format the string result. There is a value of 2.24000000001 how to limit the display of only two symbols after a point so that the result would be 2.24?


RE: String format - Daniel - 29.11.2021

Which visu?


RE: String format - admin - 29.11.2021

Use this (.2 specifies the number of decimals):
Code:
value_num = 12.3456
value_str = string.format('%0.2f', value_num)



RE: String format - sashhun - 29.11.2021

(29.11.2021, 08:32)admin Wrote: Use this (.2 specifies the number of decimals):
Code:
value_num = 12.3456
value_str = string.format('%0.2f', value_num)
Thanks