FLOAT2LONG

 
語法

        Result = FLOAT2LONG(Argument)

 

操作

        將浮點數轉換為LONG

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

 

說明

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

 

範例 

 

Sub Main()
   
Dim MyFloat As Float
   
Dim MyLong As Long   

    MyFloat =
2.4
    MyLong =
FLOAT2LONG(MyFloat)        ' the result is 2
    Debug "FLOAT2LONG of 2.4 : ", MyLong, CR
    MyFloat =
2.5
    MyLong =
FLOAT2LONG(MyFloat)        ' the result is 3
    Debug "FLOAT2LONG of 2.5 : ", MyLong, CR
    MyFloat = -
1.0
    MyLong =
FLOAT2LONG(MyFloat)        ' the result is -1
    Debug "FLOAT2LONG of -1.0 : ", MyLong, CR
    MyFloat = 4.3E9
    MyLong =
FLOAT2LONG(MyFloat)        ' the result is 2147483647
    Debug "FLOAT2LONG of 4.3E9 : ", MyLong, CR
    MyFloat = -4.3E9
    MyLong =
FLOAT2LONG(MyFloat)        ' the result is -2147483648
    Debug "FLOAT2LONG of -4.3E9 : ", MyLong, CR
End Sub