3 ms·
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
by hornd 15y ago
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.
- jonhohle 15y agoIf properly commented, why would that make you sad? I think this story is relevant: http://www.folklore.org/StoryView.py?project=Macintosh&story=Saving_Lives.txt 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 http://www.docjar.com/html/api/java/util/HashMap.java.html