View on GitHub

Quorten Blog 1

First blog for all Quorten's blog-like writings

Multiplying by a power of two in binary integers is easy: just shift left. Purportedly, it should be easy in floating point by just adding to the exponent, so long as the number is not in denormalized form. But, C doesn’t have an operator to do this, why not? The reason is that most instruction set architectures don’t have an efficient means to do this directly on floating point registers, and round-tripping between memory and floating point registers is expensive.

20200513/DuckDuckGo floating point multiply by power of two
20200513/https://stackoverflow.com/questions/12919184/why-doesnt-a-compiler-optimize-floating-point-2-into-an-exponent-increment

That’s a real bummer that you have to pay this price in energy consumption when computing with floating point. But, we’re pretty much stuck with it, so long as we use general-purpose CPUs rather than specialized DSPs or your own FPGA design.