可能有点偏差,自己改改,这个在其它语言就是一个强类型转换
CLEAR
?TRANSFORM(Test(1.0),"@0x")
?TRANSFORM(Test(1.11),"@0x")
?TRANSFORM(Test(1.2),"@0x")
?TRANSFORM(Test(2.0),"@0x")
?TRANSFORM(Test(3.0),"@0x")
?TRANSFORM(Test(4.0),"@0x")
FUNCTION Test(nNum As single) As integer
LOCAL Tmp1, Tmp2, Tmp3
DO CASE
CASE
nNum < 0
Tmp1 = 0x80000000
nNum = -nNum
CASE nNum > 0
Tmp1 = 0
OTHERWISE
RETURN 0
ENDCASE
Tmp2 = FLOOR(LOG(nNum) / LOG(2))
Tmp3 = (nNum - 2 ^ Tmp2) * 2 ^ (23 - Tmp2)
RETURN BITOR(Tmp1,BITLSHIFT(Tmp2 + 127,23),Tmp3)
End Function
或使用Dll,见附件
CLEAR
DECLARE integer F2I IN TestDll single
?F2I(1.0),TRANSFORM(F2I(1.0),"@0x")
?F2I(1.11),TRANSFORM(F2I(1.11),"@0x")
?F2I(1.2),TRANSFORM(F2I(1.2),"@0x")
?F2I(2.0),TRANSFORM(F2I(2.0),"@0x")
?F2I(3.0),TRANSFORM(F2I(3.0),"@0x")
?F2I(4.0),TRANSFORM(F2I(4.0),"@0x")
CLEAR DLLS "F2I"
[此贴子已经被作者于2021-10-24 15:31编辑过]