from typing import List
import struct


def unpack_double(data_length: int, msg, float_keep_num: int = 2) -> List[float]:
    """
    解包单精度浮点型
    :param data_length: 数据长度，原始数据有多少个数
    :param msg: 打包的消息字符串
    :param float_keep_num: 保留到小数点后的多少位
    :return: 解包结果的元素列表
    """
    origin_format = f"{data_length}d"
    format = f"{data_length * 4}h"
    b = struct.unpack(format, msg)
    r = struct.unpack(origin_format, struct.pack(format, *b))
    float_keep_num = len(str(int(float_keep_num))) + float_keep_num

    def float_to_int(x):  # 浮点数转换为指定小数位的浮点数
        r = len(str(int(x))) + float_keep_num
        return round(x, r)

    r = list(map(float_to_int, r))
    return r