XP is just a number | |
PerlMonks |
Re^3: A mod2 Machine.by Laurent_R (Canon) |
on Jul 08, 2013 at 11:54 UTC ( [id://1043100]=note: print w/replies, xml ) | Need Help?? |
I think we agree. My point is that I was using the ^ logical operation on actual binaries, something very similar to what you showed:
But I needed to show that using actual binaries, such as 0b0000111111111111 was far superior to using binary strings, i.e. something like "0000111111111111". To do this, I needed to find the best possible way to do the equivalent of ^ for strings. And it turned out that the fastest way I found was to add the strings (meaning an implicit conversion of the string to a digit), giving a result like 1111222222222222, and then (with another implicit conversion) replacing the twos by zeros (with a command like tr/2/0/) to finally get "1111000000000000". And that was four times slower than the logical ^ on actual binaries. But it was still the fastest way to do it on strings. So that, in that case, arithmetics was faster than, for example, regexes or splitting the strings into individual characters to process them one by one.. I mean seriously, why should I actually divide a number by 2 and check the remainder when I can directly check the last digit?! I definitely agree with you on that. I was only saying that there are some other cases where arithmetics is faster than other means. Although, in my case, the best, by far, was to use actual binary nombers and a logical exclusive or (4 fimes faster than artithmetics on binary strings).
In Section
Meditations
|
|