Looks like you don't have to use the tonum() function. It even fails on Lua's internal auto-conversion of strings to numbers in expressions:
> ?tostr(0+"-1",true) 0xffff.0001 |
Also, it seems to do it for all negative numbers for both styles, all the way down to the nadir value of -32768:
> ?tostr(tonum("-32768"),true) 0x8000.0001 > ?tostr(0+"-32768",true) 0x8000.0001 |
So it's probably the built-in converter that's at fault. In fact, I wouldn't be surprised if tonum() looks like this internally:
function tonum(s) return 0+s end |
Good catch, surprised no one else ran into it before... or maybe they did and neither of us did a search of the forum. ;) But either way, it needs fixing.
P#56246 2018-09-05 21:32 ( Edited 2018-09-06 02:47)
[Please log in to post a comment]