1

我试图在一个结构中获取一个指向双精度值的指针,我可以将它传递给一个例程,但是在获取除0. 以下内容适用于其他结构!我使用的值(例如只包含二进制的值!),但在这种情况下不是:

Rebol []

speed1: make struct! [
    d [double]
] [0.0]
speed1*-struct: make struct! [i [int]] third speed1
speed1*: speed1*-struct/i

下面是评测:

>>  speed1: make struct! [
[      d [double]
[     ] [0.0]
>>  speed1*-struct: make struct! [i [int]] third speed1
>>  speed1*: speed1*-struct/i
== 0

这是二进制文件的等效工作!结构:

>>  binary: make struct! [bytes [binary!]] reduce [head insert/dup copy #{} 0 8]
>>  binary*-struct: make struct! [i [int]] third binary
>>  binary*: binary*-struct/i
== 39654648

我可以看到third功能的区别:

>> third speed1
== #{0000000000000840}
>> third binary
== #{F8145D02}

但是,我不确定在这种情况下长度差异意味着什么。我究竟做错了什么?是否有不同的方法将指针传递给十进制值?

4

1 回答 1

0

这是一种获取指向双精度值的指针的方法:

speed1-struct: make struct! [s [struct! [d [double]]]] [0.0]
speed1*-struct: make struct! [i [int]] third speed1-struct
speed1*: speed1*-struct/i

并且显示它的评估返回一个指针(显示为int):

>> speed1-struct: make struct! [s [struct! [d [double]]]] [0.0]
>> speed1*-struct: make struct! [i [int]] third speed1-struct
>> speed1*: speed1*-struct/i
== 37329176
于 2014-03-24T21:00:35.827 回答