[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: comparing binary numbers with strings
- From: Shmuel Zeigerman <shmuz@...>
- Date: Fri, 26 Oct 2007 05:48:18 +0200
Merick wrote:
I was wondering if there was any way - other than using a for loop to
iterate through each character - to use the string library to compare
two strings with representations of binary numbers and tell whether or
not any of the 1's in the strings are in the same position?
Something like compare("11100", "00011") would return false and
compare("11100","00111") would return true
function compare(a,b)
a = tostring(tonumber(a) + tonumber(b))
return a:match"2"
end
--
Shmuel