Arithmetic Bit Shift of Double Variable Data Type in C

Bitwise shifting a floating point data type will not give you the result you're looking for.

In Simulink, the Shift Arithmetic block only does bit shifting for integer data types. If you feed it a floating point type it divides the input signal by 2^N where N is the number of bits to shift specified in the mask dialog box.

EDIT:
Since you don't have the capability to perform any floating point math your options are:

  • understand the layout of a floating point single precision number, then figure out how to manipulate it bitwise to achieve division.
  • convert whatever algorithm you're porting to use fixed point data types instead of floating point

I'd recommend option 2, it's a whole lot easier than 1


Bit-shifting a floating-point data type (reinterpreted as an int) will give you gibberish (take a look at the diagrams of the binary representation here to see why).

If you want to multiply/divide by a power of 2, then you should do that explicitly.