docs: def float_to_fp(signed, n_bits, n_frac):
      """Return a function to convert a floating point value to a fixed point
      value.
  
      For example, a function to convert a float to a signed fractional
      representation with 8 bits overall and 4 fractional bits (S3.4) can be
      constructed and used with::
  
          >>> s34 = float_to_fp(signed=True, n_bits=8, n_frac=4)
          >>> hex(int(s34(0.5)))
          '0x8'
  
      The fixed point conversion is saturating::
  
          >>> q34 = float_to_fp(False, 8, 4)  # Unsigned 4.4
          >>> hex(int(q34(-0.5)))
          '0x0'
  
          >>> hex(int(q34(15.0)))
          '0xf0'
  
          >>> hex(int(q34(16.0)))
          '0xff'
  
      Parameters
      ----------
      signed : bool
          Whether the values that are to be converted should be signed, or
          clipped at zero.
  
              >>> hex(int(float_to_fp(True, 8, 4)(-0.5)))  # Signed
              '-0x8'
              >>> hex(int(float_to_fp(False, 8, 4)(-0.5)))  # Unsigned
              '0x0'
  
      n_bits : int
          Total number of bits in the fixed-point representation (including sign
          bit and fractional bits).
      n_frac : int
          Number of fractional bits in the fixed-point representation.
      """
      # Calculate the maximum and minimum values
      if signed:
          max_v = (1 << (n_bits - 1)) - 1
          min_v = -max_v - 1
      else:
          min_v = 0
          max_v = (1 << n_bits) - 1
  
      # Compute the scale
      scale = 2.0**n_frac
  
      def bitsk(value):
          """Convert a floating point value to a fixed point value.
  
          Parameters
          ----------
          value : float
              The value to convert.
          """
          int_val = int(scale * value)
          return max((min(max_v, int_val), min_v))
  
      return bitsk