perl6 - 将Blob中的数据转换为Num

Mar*_*rth 6 representation perl6

我在blob中有一些字节,二进制数据的不可变缓冲区,我正在寻找一种方法将它所包含的内容转换为浮点数据结构Num,因为它是适合所有这3种格式的类.在$ blob中

  1. IEEE Float
  2. IEEE Double
  3. IEEE Long Double

进行转换的最佳方式是什么?

Chr*_*oph 9

导入NativeCall,对所需类型的指针执行强制转换并取消引用结果:

use NativeCall;
nativecast(Pointer[num32], $blob).deref;
Run Code Online (Sandbox Code Playgroud)