0

I want to ask if it is possible to divide the floating-point or fixed number using the shift operators. I want to divide the floating-point or fixed number in the power of 2? I know for decimal numbers we can use shift operators in Verilog HDL for division and multiplication.

  • Ignoring overflow/underflow problems you can divide by a power of two, by subtracting that number from the exponent part. For binary fixed point numbers you can do ordinary shifting. – chtz Jun 03 '20 at 08:20

1 Answers1

0

If you really want to divide (bit-shift) a float number, you could use a method called fixed-point.

Say you will (say) hold the number 1.45 (and bit-shift it later). You would store 145 in an integer, and every time you accessed the variable you would divide the value by 2 using shift right operation.

Mohsen Alyafei
  • 4,765
  • 3
  • 30
  • 42
  • 2
    Saying “If you really want to divide (bit-shift) a float number, you could use a method called fixed-point” is like saying if you really want to drive a car, you could ride a train. “Float,” also known as floating-point, numbers are in a specific kind of format where there is an exponent that makes the decimal or radix point “float.” If you use fixed-point, you are not using floating-point. – Eric Postpischil Jun 03 '20 at 10:45