【问题标题】:perl6 - Converting data in a Blob into a Numperl6 - 将 Blob 中的数据转换为 Num
【发布时间】:2018-10-09 16:39:36
【问题描述】:

我在blob, an immutable buffer for binary data 中有一些字节,我正在寻找一种方法将它保存的内容转换为floating point data structure, Num,因为它是适合所有可能在 $blob 中的所有这 3 种格式的类

  1. IEEE 浮点数
  2. IEEE 双
  3. IEEE 长双

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

【问题讨论】:

    标签: raku representation


    【解决方案1】:

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

    use NativeCall;
    nativecast(Pointer[num32], $blob).deref;
    

    【讨论】:

    • 好像没有IEEE Long Double的类型?我找不到 num128
    猜你喜欢
    • 1970-01-01
    • 2018-08-06
    • 1970-01-01
    • 2021-07-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多