def float_to_byte(value, mantissabits = 5, zeroexp = 2):
    """Encodes a floating point number in a single byte.
    """
    
    # Assume int size == float size
    
    fzero = (63 - zeroexp) << mantissabits
    bits = unpack("i", pack("f", value))[0]
    smallfloat = bits >> (24 - mantissabits)
    if fzero < smallfloat:
        # Map negative numbers and 0 to 0
        # Map underflow to next smallest non-zero number
        if bits <= 0:
            return chr(0)
        else:
            return chr(1)
    elif smallfloat >= fzero + 0x100:
        # Map overflow to largest number
        return chr(255)
    else:
        return chr(smallfloat - fzero)
dataset/ETHPy150Open dokipen/whoosh/src/whoosh/util.py/float_to_byte/swapped operands of `<`