lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Just for the record, the error was in one of our C modules...

Am 10.02.2016 um 20:07 schrieb Roberto Ierusalimschy <roberto@inf.puc-rio.br>:

>> Would string.format("%u", a) be preferred over using type coercion with
>> something like a|0
> 
> They do different things for different needs. If you need a numeral in a
> specific format (as in the original post, where something like "14.0" is
> invalid), you should always use 'string.format' to produce the numeral
> with the format you need. 'print' and 'tostring' have always had the
> freedom to format the number in their own way.
> 
> If you need a number internally as an integer, you could use 'a|0'. But
> you should always first check why the number is not an integer in the
> first place.  More often than not, numbers that should be integers are
> integers. (That is the main reason for the ".0" in 'print'; it calls
> attention to these smells in our code.)
> 
> -- Roberto
>