FLOAT2INTEGER

 
語法

        Result = FLOAT2INTEGER(Argument)

 

操作

        將浮點數轉換為整數。

  • Argument FLOAT2INTEGER函數的浮點運算元。
  • Result 用來接收FLOAT2INTEGER函數結果的整數變數。

 

說明

        FLOAT2INTEGER指令將浮點數轉換為整數。小數的部分會被四捨五入。如果值超過整數值的範圍,則會使用數值+32767-32768

 

範例

 

Sub Main()
   
Dim MyFloat As Float
   
Dim MyInteger As Integer

    MyInteger =
22
   
Debug "MyInteger : ", MyInteger, CR
    MyFloat =
2.4
    MyInteger =
FLOAT2INTEGER(MyFloat)      'the result is 2
    Debug "FLOAT2INTEGER of 2.4 : ", MyInteger, CR
    MyFloat =
2.5
    MyInteger =
FLOAT2INTEGER(MyFloat)      ' the result is 3
    Debug "FLOAT2INTEGER of 2.5 : ", MyInteger, CR
    MyFloat = -
1.0
    MyInteger =
FLOAT2INTEGER(MyFloat)      ' the result is -1
    Debug "FLOAT2INTEGER of -1.0 : ", MyInteger, CR
    MyFloat =
32768.0
    MyInteger =
FLOAT2INTEGER(MyFloat)      ' the result is 32767
    Debug "FLOAT2INTEGER of 32768.0 : ", MyInteger, CR
    MyFloat = -
32769.0
    MyInteger =
FLOAT2INTEGER(MyFloat)      ' the result is -32768
    Debug "FLOAT2INTEGER of -32769.0 : ", MyInteger, CR
End Sub