用python转换浮点数为16进制怎么写
导读:用python转换浮点数为16进制怎么写?# -*- coding: utf8 -*-import ctypesdef h2f(s : cp = ctypes.pointer(ctypes.c_longlong(s fp =...
用python转换浮点数为16进制怎么写?
# -*- coding: utf8 -*-import ctypesdef h2f(s): cp = ctypes.pointer(ctypes.c_longlong(s)
) fp = ctypes.cast(cp, ctypes.POINTER(ctypes.c_double)
) return fp.contents.valuedef f2h(s): fp = ctypes.pointer(ctypes.c_double(s)
) cp = ctypes.cast(fp, ctypes.POINTER(ctypes.c_longlong)
) return hex(cp.contents.value)print(f2h(34.4536)
)print(h2f(0x40413a0f9096bb99))
声明:本文内容由网友自发贡献,本站不承担相应法律责任。对本内容有异议或投诉,请联系2913721942#qq.com核实处理,我们将尽快回复您,谢谢合作!
若转载请注明出处: 用python转换浮点数为16进制怎么写
本文地址: https://pptw.com/jishu/61952.html
