FLOAT2WORD

 
語法

        Result = FLOAT2WORD(Argument)

 

操作

        將浮點數轉換為Word

  • Argument FLOAT2WORD函數的浮點運算元。
  • Result 接收FLOAT2WORD函數結果的Word變數。

 

說明

        FLOAT2WORD指令將浮點數轉換為Word。小數的部分會被四捨五入。如果值超過Word值的範圍,則會使用數值065535

 

範例

 Sub Main()

    Dim MyFloat As Float
   
Dim MyWord As Word

    MyFloat =
2.4
    MyWord =
FLOAT2WORD(MyFloat)        ' the result is 2
    Debug "FLOAT2WORD of 2.4 : ", MyWord, CR
    MyFloat =
2.5
    MyWord =
FLOAT2WORD(MyFloat)        ' the result is 3
    Debug "FLOAT2WORD of 2.5 : ", MyWord, CR
    MyFloat = -
1.0
    MyWord =
FLOAT2WORD(MyFloat)        ' the result is 0
    Debug "FLOAT2WORD of -1.0 : ", MyWord, CR
    MyFloat =
65536.0
    MyWord =
FLOAT2WORD(MyFloat)        ' the result is 65535
    Debug "FLOAT2WORD of 65536 : ", MyWord, CR
End Sub