Double 資料類型 (Visual Basic)Double Data Type (Visual Basic)

保存已簽署的 IEEE 64 位 (8 位元組) 雙精確度浮點數, 範圍介於-1.79769313486231570 E + 308 到-4.94065645841246544 E-324 中的負值, 以及從 4.94065645841246544 E-324 到 1.79769313486231570 E + 308 的值正數值。Holds signed IEEE 64-bit (8-byte) double-precision floating-point numbers that range in value from -1.79769313486231570E+308 through -4.94065645841246544E-324 for negative values and from 4.94065645841246544E-324 through 1.79769313486231570E+308 for positive values. 雙精度浮點數會儲存實數的近似值。Double-precision numbers store an approximation of a real number.


Double資料類型會針對某個數位提供最大和最小的可能巨量。The Double data type provides the largest and smallest possible magnitudes for a number.

Double 的預設值為 0。The default value of Double is 0.

程式設計提示Programming Tips

  • 精密.Precision. 當您使用浮點數時, 請記住它們不一定會在記憶體中有精確的標記法。When you work with floating-point numbers, remember that they do not always have a precise representation in memory. 這可能會導致某些作業產生非預期的結果, 例如值比較和Mod運算子。This could lead to unexpected results from certain operations, such as value comparison and the Mod operator. 如需詳細資訊, 請參閱針對資料類型進行疑難排解For more information, see Troubleshooting Data Types.

  • 尾端零。Trailing Zeros. 浮點資料類型沒有尾端零字元的任何內部表示。The floating-point data types do not have any internal representation of trailing zero characters. 例如, 它們不會區分4.2000 和4.2。For example, they do not distinguish between 4.2000 and 4.2. 因此, 當您顯示或列印浮點值時, 不會出現尾端的零字元。Consequently, trailing zero characters do not appear when you display or print floating-point values.

  • 輸入字元。Type Characters. 將常值類型字元 R 附加到常值,會強制其成為 Double 資料類型。Appending the literal type character R to a literal forces it to the Double data type. 例如, 如果整數值後面接著R, 則值會變更Double為。For example, if an integer value is followed by R, the value is changed to a Double.

    ' Visual Basic expands the 4 in the statement Dim dub As Double = 4R to 4.0:
    Dim dub As Double = 4.0R

    將識別項類型字元 # 附加到任何識別項,會強制其成為 DoubleAppending the identifier type character # to any identifier forces it to Double. 在下列範例中, 變數num的類型Double為:In the following example, the variable num is typed as a Double:

    Dim num# = 3
  • 架構類型。Framework Type. 在 .NET Framework 中對應的類型為 System.Double 結構。The corresponding type in the .NET Framework is the System.Double structure.

另請參閱See also