News for hackers. Stuff that matters.
Re:Bit Twiddling Hacks by hornd on Wednesday January 11, 2012 @01:54PM (#3453075)
These are pretty neat. I use a few of them relatively often at work, but if I ever saw

c = ((((c - 0x3f800000) >> r) + 0x3f800000) >> 23) - 127;

in production code I would be sad.

Re:Bit Twiddling Hacks by jonhohle on Wednesday January 11, 2012 @03:14PM (#3453452)
If properly commented, why would that make you sad?

I think this story is relevant: http://www.folklore.org/StoryView.py?project=Macintosh&s...

Think of all of the time software wastes in people's lives by being bloated and inefficient.

In Java, for example, the default HashMap implementation [0] uses a while loop to compute the capacity of the array it will use as storage. Using the next highest power of two algorithm in the page listed is faster than this loop. Imagine if every JVM was microseconds faster every time a HashMap was allocated or resized. On one server, computer, or phone it's meaningless. On hundreds of millions of phones phones, PCs, and servers that adds up to meaningful amounts of time and energy.

[0] http://www.docjar.com/html/api/java/util/HashMap.java.html