keon / awesome-bits Goto Github PK
View Code? Open in Web Editor NEW:computer: A curated list of awesome bitwise operations and tricks
:computer: A curated list of awesome bitwise operations and tricks
Fast color conversion from R5G5B5 to R8G8B8 pixel format using shifts
R8 = (R5 << 3) | (R5 >> 2)
G8 = (R5 << 3) | (R5 >> 2)
B8 = (R5 << 3) | (R5 >> 2)
This looks to assign the same value to R8, G8 and B8
See this page for a correct implementation of round
.
I'll put a testing code in c for each of the tricks.
Shifting by a negative value is undefined behaviour in C. Also you should make sure that the second operand is never higher than or equal to the bit-width of the left-hand type, since that is undefined as well.
I assume "Modulo 2n against m" means m % (pow(2, n))
. In that case, for m=11
and n = 3
, m & (n - 1)
gives 2
, but 11 % 8
gives 3
. Perhaps you mean m & ((1 << n) - 1)
?
a ^= b;
b ^= a;
a ^= b;
this technique should be discouraged, at least notes should be added. as it is by no means better than the temp
approach. looking from the execution instruction perspective.
Find this repo really helpful.
So I translated it into Chinese.
https://github.com/RangerCD/awesome-bits/tree/zh_cn
I was wondering if you could start a new branch or add a link somewhere.
Hey @KeonKim,
It looks like this repository would really benefit from having some LaTeX typesetting. I'd be happy to set up a natural-looking typesetting script if you would like; the downside is that contributors will need to have some prerequisites and will need to run a script on check-out. Let me know if you think this might be a good idea. For reference, the renderer is at https://github.com/leegao/readme2tex
I think that should say "power" of 2, not "factorial" =)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.