#bittwiddling — Public Fediverse posts
Live and recent posts from across the Fediverse tagged #bittwiddling, aggregated by home.social.
-
A neat explanation:
“That XOR Trick” [2020], Florian Hartmann (https://florian.github.io//xor-trick/).
On HN: https://news.ycombinator.com/item?id=25821718 & https://news.ycombinator.com/item?id=44425880
-
The mother lode of #BitTwiddling tips (apart from the #book “Hacker’s Delight”, by Henry S. Warren Jr, and “HAKMEM” by the MIT hackers):
“Bit Twiddling Hacks”, Sean Eron Anderson (https://graphics.stanford.edu/~seander/bithacks.html).
-
This 👇🏽 is good 👌🏽:
“A Leap Year Check In Three Instructions”, Falk Hüffner (https://hueffner.de/falk/blog/a-leap-year-check-in-three-instructions.html).
Via HN: https://news.ycombinator.com/item?id=43999748
On Lobsters: https://lobste.rs/s/ybjgex/leap_year_check_three_instructions
#Optimization #Assembly #Compilers #GCC #Math #LeapYear #GregorianCalendar #BitTwiddling #Speed
-
I'm sure this has been done many times before, but I'm still happy to be bit-twiddling in #shaders. The star is this line:
(vertex_index & 3u) + (vertex_index >> 2u)
"Give me the first two bits but add one if the third bit is set.”
The shader generates a UV-mapped quad (right-triangle pair) from the 0 through 5 vertex indices. The screenshot code is abridged; full code is at the link.
https://github.com/shanecelis/bevy/blob/add-viewport-post-processing/crates/bevy_core_pipeline/src/viewport_vertex_shader/viewport.wgsl #gamedev #bevyengine #bittwiddling #wgsl
-
In 2013, past me wrote some mysterious code. Effectively, it was this.
uint8_t decay(uint8_t x) { return (x >> 1) | (x >> 2); }
Sort of a low level multiply by 0.75, but with an | instead of a +. The target was an 8 bit AVR. Is there any good reason for using | here? I vaguely remember a bug where certain values didn't decay, but testing shows all 255 nonzero values of x do decay.
Any thoughts?
-
Re: coding.
If it ain't native ASM, it ain't shit.
POP!
**scampers away cackling maniacally**
-
I made a tiny #Swift package for decoding Base32 values.
-
Little Hex Tricks Make Little Displays a Little Easier - Depending on the device in hand and one’s temperament, bringing up a new part can be a frolic throug... more: https://hackaday.com/2020/01/24/little-hex-tricks-make-little-displays-a-little-easier/ #microcontrollers #bitmanipulation #computerhacks #bittwiddling #spreadsheet #registers #7segment #how-to #excel #issi #led #c
-
These Bit Twiddling Tricks Will Make Your Coworkers Hate You - In the embedded world, twiddling a few bits is expected behavior. Firmware is far enough down the st... more: https://hackaday.com/2020/01/16/these-bit-twiddling-tricks-will-make-your-coworkers-hate-you/ #bitmanipulation #softwarehacks #classichacks #bittwiddling #registers #bitmath #shift #bits #mask