在 Julia 中将 int 和 float 打包为字节数组 [英] Packing int and float to byte arrays in Julia
本文介绍了在 Julia 中将 int 和 float 打包为字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
I am trying to find out how I can pack an integer or float value in to a byte array in Julia. In Python I would just do the following:
struct.pack("<q",1)
Which would give me 'x01x00x00x00x00x00x00x00'
or for a float:
struct.pack("<f",0.1)
Is there any package in Julia that provides this?
Thanks!
解决方案
See the StrPack package: https://strpackjl.readthedocs.org/en/latest/
This is actually one of the oldest Julia packages around.
这篇关于在 Julia 中将 int 和 float 打包为字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文