将int和float打包到Julia中的字节数组 [英] Packing int and float to byte arrays in Julia

查看:100
本文介绍了将int和float打包到Julia中的字节数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图找出如何将整数或浮点值打包到Julia中的字节数组中.在Python中,我将执行以下操作:

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)

哪个会给我'\ x01 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00 \ x00'

Which would give me '\x01\x00\x00\x00\x00\x00\x00\x00'

或浮动:

struct.pack("<f",0.1)

Julia中有提供此功能的软件包吗?

Is there any package in Julia that provides this?

谢谢!

推荐答案

请参阅StrPack软件包: https: //strpackjl.readthedocs.org/en/latest/

See the StrPack package: https://strpackjl.readthedocs.org/en/latest/

这实际上是周围最古老的Julia软件包之一.

This is actually one of the oldest Julia packages around.

这篇关于将int和float打包到Julia中的字节数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆