ページ 11

getSingle関数の使い方?

Posted: 2008年7月11日(金) 18:09
by ゲスト
下記のようなことをしてみたのですが、getSingle関数の戻り値が変(0)です。
使い方を間違っているのでしょうか?
Doubleの方は、期待値どおりなんですが。
使っているのは、4.24.00です。

#prompt
dim tmp as single
dim temp as double
dim buf[7] as byte
buf[3]=&hc3:buf[2]=&h28:buf[1]=&hb9:buf[0]=&h6b
buf[7]=&hc3:buf[6]=&h28:buf[5]=&hb9:buf[4]=&h6b

print getSingle(buf)
memcpy(VarPtr(tmp),buf,4)
print tmp

print getDouble(buf)
memcpy(VarPtr(temp),buf,8)
print temp

Posted: 2008年7月11日(金) 19:39
by konisi
バグですね。
次のように回避してください。

コード: 全て選択

#prompt
dim tmp as single
dim temp as double
dim buf[7] as byte
buf[3]=&hc3:buf[2]=&h28:buf[1]=&hb9:buf[0]=&h6b
buf[7]=&hc3:buf[6]=&h28:buf[5]=&hb9:buf[4]=&h6b

print getSingle2(buf)
memcpy(VarPtr(tmp),buf,4)
print tmp

print getDouble(buf)
memcpy(VarPtr(temp),buf,8)
print temp

Function getSingle2(lpSingle As VoidPtr) As Single
	SetDWord(VarPtr(getSingle2),GetDWord(lpSingle))
End Function