def get_conv(bits, bin_point, signed=False, scaling=1.0):
    """
    Creates a I{conversion structure} implented as a dictionary containing all parameters
    needed to switch between number representations.
    @param bits: the number of bits
    @param bin_point: binary point position
    @param signed: True if Fix, False if UFix
    @param scaling: optional scaling to be applied after the conversion
    @return: a conversion structure that can be applied in both directions of
    conversion for the given specs.
    """
    conversion_t = {}
    conversion_t["bits"] = bits
    conversion_t["bin_point"] = bin_point
    conversion_t["signed"] = signed
    conversion_t["scaling"] = scaling
    conversion_t["dec_step"] = 1.0 / (2 ** bin_point)
    #dec_max = dec_mask * dec_step
    conversion_t["dec_mask"] = sum([2 ** i for i in range(bin_point)])
    if bits == 8:
        conversion_t["fmt"] = "B"
    elif bits == 16:
        conversion_t["fmt"] = "H"
    elif bits == 32:
        conversion_t["fmt"] = "I"
    else:
        raise ConversionError("numer of bits not supported: " + str(bits))
    if signed:
        _get_signed_params(conversion_t)
    else:
        _get_unsigned_params(conversion_t)
    return conversion_t
def get_conv ( bits , bin_point , signed = False , scaling = 1.0 ) : conversion_t = { } conversion_t [ "bits" ] = bits conversion_t [ "bin_point" ] = bin_point conversion_t [ "signed" ] = signed conversion_t [ "scaling" ] = scaling conversion_t [ "dec_step" ] = 1.0 / ( 2 ** bin_point ) conversion_t [ "dec_mask" ] = sum ( [ 2 ** i for i in range ( bin_point ) ] ) if bits == 8 : conversion_t [ "fmt" ] = "B" elif bits == 16 : conversion_t [ "fmt" ] = "H" elif bits == 32 : conversion_t [ "fmt" ] = "I" else : raise ConversionError ( "numer of bits not supported: " + str ( bits ) ) if signed : _get_signed_params ( conversion_t ) else : _get_unsigned_params ( conversion_t ) return conversion_t
Creates a I{conversion structure} implented as a dictionary containing all parameters
    needed to switch between number representations.
    @param bits: the number of bits
    @param bin_point: binary point position
    @param signed: True if Fix, False if UFix
    @param scaling: optional scaling to be applied after the conversion
    @return: a conversion structure that can be applied in both directions of
    conversion for the given specs.