本文介绍了perl6-将Blob中的数据转换为Num的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在 blob(二进制数据的不可变缓冲区)中有一些字节,并且我正在寻找一种将其保存为浮点数据结构Num
,因为这是适合$ blob中所有这3种格式的类
What would be the best way of doing that conversion?
推荐答案
导入NativeCall
,执行对所需类型的指针的转换并取消引用结果:
Import NativeCall
, perform a cast to a pointer of desired type and dereference the result:
use NativeCall;
nativecast(Pointer[num32], $blob).deref;
这篇关于perl6-将Blob中的数据转换为Num的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!