Have you ever had to use bit shifting in real projects? [closed]

I still write code for systems that do not have floating point support in hardware. In these systems you need bit-shifting for nearly all your arithmetic. Also you need shifts to generate hashes. Polynomial arithmetic (CRC, Reed-Solomon Codes are the mainstream applications) or uses shifts as well. However, shifts are just used because they are … Read more

Converting Int to Float or Float to Int using Bitwise operations (software floating point)

First, a paper you should consider reading, if you want to understand floating point foibles better: “What Every Computer Scientist Should Know About Floating Point Arithmetic,” http://www.validlab.com/goldberg/paper.pdf And now to some meat. The following code is bare bones, and attempts to produce an IEEE-754 single precision float from an unsigned int in the range 0 … Read more

What is this asm style “x | 0” some javascript programmers are now using?

According to JavaScript Performance for Madmen Wrapping integer arithmetic expressions in ( ) | 0 allows the runtime to be sure that you’re doing integer arithmetic instead of floating-point arithmetic. This allows it to avoid checking for overflow and produce faster code in many cases. and according to the page, it’s true for “most” Javascript … Read more