Live data from Hacker News

FizzleFade

fabiensanglard.net

81–90 of 182 posts

Re: FizzleFade

#81
post #4

Cool, I knew that LFSRs were used in ciphers. I was not aware that they were also useful for implementing old-school graphical effects. https://en.wikipedia.org/wiki/Linear-feedback_shift_register...

Similar concepts are used for raid 6 parity (LSFR + Galois Fields). A pdf I found describing raid 6 parity describes the field and LSFR use and some background. https://www.kernel.org/pub/linux/kernel/people/hpa/raid6.pdf

(I took at stab at implementing them awhile back as an experiment. https://github.com/jimktrains/r6parity)

Re: FizzleFade

#82

What properties are required in an LFSR that it covers the whole range (2^n-1 numbers) before returning? Or are such configurations found experimentally?

A pdf I found describing raid 6 parity describes it. https://www.kernel.org/pub/linux/kernel/people/hpa/raid6.pdf That PDF + the sibling comment should help in understanding.

(I took a stab at implementing it in C a few years back. https://github.com/jimktrains/r6parity)

Re: FizzleFade

#83
post #79

Earlier quoted context omitted.

I remember a recent example. What I wrote was: int x = somefunction(); int x_dividedby16 = x >> 4; My coworker corrected the second line to something like: int x_dividedby16 = (int)Math.ceil(x / 16.0);

Why not `x / 16`?

Integer division will give a rounded result instead of floor

Re: FizzleFade

#87

Earlier quoted context omitted.

Why? I mean if you look at the majority of work that programmers do today - frontend/backend web development and apps, there is no need to have knowledge about bits. In fact, if I see someone using binary operators in languages such as Java,JS,Ruby etc... I'll immediately consider it bad code, regardless of context - it's just not the right tool for the level of abstraction in these languages. The fact is that in the…

I remember a recent example. What I wrote was: int x = somefunction(); int x_dividedby16 = x >> 4; My coworker corrected the second line to something like: int x_dividedby16 = (int)Math.ceil(x / 16.0);

[deleted]

Re: FizzleFade

#88
post #51

as a "senior" business programmer with non-engineering studies (I have a deegree in byology), I'm feeling an impostor reading this and admitting that I'm unable to understand basically everything... even https://bigmachine.io/products/the-imposters-handbook/ not helped too much

It's very simple. Basically you need to cycle through all n-bit integers (except zero) in a random-looking way, and it turns out there's an arcane-ish bit twiddling operation that will do it when applied repeatedly. The reason it works can be explained with some undergrad math. You don't need to know these things for business programming but they are fun to read about.

Another idea in a similar vein is https://en.wikipedia.org/wiki/Floyd%E2%80%93Steinberg_dither... It converts an image with many shades of gray to an image with only black and white pixels. The algorithm is dead simple, but the results are surprisingly convincing.

Re: FizzleFade

#89

Earlier quoted context omitted.

Why? I mean if you look at the majority of work that programmers do today - frontend/backend web development and apps, there is no need to have knowledge about bits. In fact, if I see someone using binary operators in languages such as Java,JS,Ruby etc... I'll immediately consider it bad code, regardless of context - it's just not the right tool for the level of abstraction in these languages. The fact is that in the…

I remember a recent example. What I wrote was: int x = somefunction(); int x_dividedby16 = x >> 4; My coworker corrected the second line to something like: int x_dividedby16 = (int)Math.ceil(x / 16.0);

[deleted]

Re: FizzleFade

#90

Earlier quoted context omitted.

Why? I mean if you look at the majority of work that programmers do today - frontend/backend web development and apps, there is no need to have knowledge about bits. In fact, if I see someone using binary operators in languages such as Java,JS,Ruby etc... I'll immediately consider it bad code, regardless of context - it's just not the right tool for the level of abstraction in these languages. The fact is that in the…

I remember a recent example. What I wrote was: int x = somefunction(); int x_dividedby16 = x >> 4; My coworker corrected the second line to something like: int x_dividedby16 = (int)Math.ceil(x / 16.0);

I'd only ever use a bitshift if the intention of the code was to move the bits left or right (e.g. moving red, green or blue pixel component bits into the right position) or if it was absolutely required for speed as it's less readable if your intention is to divide a number. C compilers will easily optimise simple integer divisions like this for example.
Post reply on HN