About 59,500 results
Open links in new tab
  1. c - Lua - Number to string behaviour - Stack Overflow

    Mar 16, 2016 · It is going to convert to an int (as string) if the number is round (i.e if number == (int) number) or is it always going to output a real (as string) like 10.0? I need to mimic the exact behaviour of Lua's tostring in C, without using the Lua C …

  2. Lua string to int - Stack Overflow

    Jun 25, 2019 · In which case you explicitly convert the string (or really, whatever it is) into a number, and then truncate the number like an (int) cast would do in Java. Edit: This still works in Lua 5.3, even thought Lua 5.3 has real integers, as math.floor() returns an integer, whereas an operator such as number // 1 will still return a float if number is ...

  3. types - Convert integer to string in lua? - Stack Overflow

    Apr 23, 2018 · For complete control of how numbers are converted, use string.format. If the metatable of e has a "__tostring" field, then tostring calls the corresponding value with e as argument, and uses the result of the call as its result. tostring is mentioned in Chapter 1, page 1 of the NSpire Lua Scripting API Reference Guide...

  4. floating point - Lua: converting from float to int - Stack Overflow

    Even though Lua does not differentiate between floating point numbers and integers, there are some cases when you want to use integers. What is the best way to covert a number to an integer if you cannot do a C-like cast or without something like Python's int? For example when calculating an index for an array in . idx = position / width

  5. lua - Converting integer value to a string - Stack Overflow

    May 13, 2014 · @Dick, most Lua implementations don't have an integer type nor integer operations. Unless you find out otherwise, you can assume that the number type is implemented as an IEEE-754 double. – Tom Blodget

  6. Lua: print integer as a binary - Stack Overflow

    Jan 31, 2012 · In Lua 5.2 you've already have bitwise functions which can help you ( bit32) Here is the most-significant-first version, with optional leading 0 padding to a specified number of bits: function toBits(num,bits) -- returns a table of bits, most significant first.

  7. How do I convert string of hex digits to value it represents in Lua

    Mar 22, 2012 · Convert string to numbers in Lua. 10. Convert decimal to hex in Lua 4? 2. Decimal to Hexadecimal ...

  8. How to convert string to boolean in lua - Stack Overflow

    Oct 1, 2021 · I want to convert this value to true or false in lua datatype. Currently, I can do this long way: if value == "false" then value=false elseif value == "true" then value=true end Is there a simplest way to convert this like converting string to integer tonumber("1")

  9. Convert string to numbers in Lua - Stack Overflow

    Jun 2, 2016 · In Lua, I have a string like this: 231 523 402 1223 9043 -1 4 which contains several numbers separated by space. Now I would like to convert it into a vector of int numbers, how to achieve it with ...

  10. lua - String to number conversion - Stack Overflow

    May 28, 2013 · Lua string to int. 3. Converting calculation string to int in Lua. 4. ... Convert string to numbers in Lua ...

  11. Some results have been removed
Refresh