Skip to content

Commit ae0b889

Browse files
Add info on string to number conversion
This is useful for unpacking multiples numbers from strings. The technique can be seen in here: http://www.lexaloffle.com/bbs/?pid=25441#p25441
2 parents b2cdf73 + 6911897 commit ae0b889

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

index.html

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -403,7 +403,10 @@ <h6>private functions (use carefully)</h6>
403403
<h6>string manipulation</h6>
404404
<pre><code class="lua">#s -- string length
405405
"three "..4 -- string concatenation
406-
sub(str, from, [to]) -- substring</code></pre>
406+
sub(str, from, [to]) -- substring
407+
"123.45" + 0 -- convert string to a number
408+
-- string must be parseable as a number
409+
-- use "0xAF" format for hex numbers</code></pre>
407410

408411
<h6>special characters</h6>
409412
<pre><code class="lua">print('l:\x8b r:\x91 u:\x94 d:\x83 o:\x8e x:\x97')</code></pre>

0 commit comments

Comments
 (0)