[Nottingham] A Little Coding Gem
Mike Cardwell
nlug at lists.grepular.com
Thu Nov 15 23:33:05 UTC 2012
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA512
On 15/11/12 22:09, Martin wrote:
> We have a mix of "big endian" and "little endian" systems, however
> that is of little concern being as whatever endian-ness is
> untangled at whatever communications or storage interface is used.
Also, big/little endian tends to apply to the order of bytes, whereas
this bit of code changed the order of the bits inside the bytes too.
Also, I feel the need to correct myself: this horrible bit of code
which I pasted into that pastebin:
str += (n >> i << (sizeof(n)*8-1) >> (sizeof(n)*8-1)) ? '1' : '0';
Can be replaced with the much simpler:
str += (n >> i & 1) ? '1' : '0';
- --
Mike Cardwell https://grepular.com/ http://cardwellit.com/
OpenPGP Key 35BC AF1D 3AA2 1F84 3DC3 B0CF 70A5 F512 0018 461F
XMPP OTR Key 8924 B06A 7917 AAF3 DBB1 BF1B 295C 3C78 3EF1 46B4
-----BEGIN PGP SIGNATURE-----
iQGGBAEBCgBwBQJQpXxcMBSAAAAAACAAB3ByZWZlcnJlZC1lbWFpbC1lbmNvZGlu
Z0BwZ3AuY29tcGdwbWltZTgUgAAAAAAVABpwa2EtYWRkcmVzc0BnbnVwZy5vcmdt
aWtlLmNhcmR3ZWxsQGdyZXB1bGFyLmNvbQAKCRCdJiMBwdHnBKRvB/9+hWYfGhQ9
asxu0rAq8gQQSZa9blf5ueGYM6Dlbx1zHjVArZcJYWFEIrlBjjuaZsbrBH6FeWOS
D8rGkRd139G0fNJUctf5HvElM5raqrKmgnSc/zAImIvBAQsnv22yMR+ky7PKECT/
W9BQTYJ/QpUr6Y6lB2erz0Y+N05FeDjwiNgYlk86UWUP+QquDN4zkOqzjZUPcGX4
Ho99HxZQlcGwbmujSnXuHDJC2IjhS5r0w1GL5uX63M7wCXwVxMsLFycZQh8UD8/D
seZ+GG1xS12ucjlie/EfbBtla5A39nKtyydox1y17rzK6ThgEAGf56rc5p1AwFDk
YhILfLeLcuee
=Stjn
-----END PGP SIGNATURE-----
More information about the Nottingham
mailing list