字串資料類型 (Visual Basic)Single Data Type (Visual Basic)

保存帶正負號的 IEEE 32 位元 (4 個位元組) 單精確度浮點數,值範圍從-3.4028235E + 38 到-1.401298E-45 負值,以及從 1.401298E-45 到 3.4028235E + 38 的正數值。Holds signed IEEE 32-bit (4-byte) single-precision floating-point numbers ranging in value from -3.4028235E+38 through -1.401298E-45 for negative values and from 1.401298E-45 through 3.4028235E+38 for positive values. 單精確度數字儲存的是實數的近似值。Single-precision numbers store an approximation of a real number.

備註Remarks

使用Single資料類型可包含不需要完整的資料寬度的浮點值DoubleUse the Single data type to contain floating-point values that do not require the full data width of Double. 在某些情況下的 common language runtime 可能可以將封裝您Single緊密合作,並將記憶體耗用量儲存的變數。In some cases the common language runtime might be able to pack your Single variables closely together and save memory consumption.

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

程式設計提示Programming Tips

  • 有效位數。Precision. 當您使用浮點數時,記住其在記憶體中不一定有精確的表示法。When you work with floating-point numbers, keep in mind 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.

  • 擴展。Widening. Single資料類型可擴展為DoubleThe Single data type widens to Double. 這表示您可以將轉換SingleDouble而不會發生System.OverflowException時發生錯誤。This means you can convert Single to Double without encountering a System.OverflowException error.

  • 尾端零。Trailing Zeros. 浮點資料類型沒有任何結尾 0 字元的內部表示法。The floating-point data types do not have any internal representation of trailing 0 characters. 比方說,它們無法區分 4.2000 與 4.2。For example, they do not distinguish between 4.2000 and 4.2. 因此,結尾 0 字元時,沒有出現在顯示或列印浮點數的值。Consequently, trailing 0 characters do not appear when you display or print floating-point values.

  • 類型字元。Type Characters. 將常值類型字元 F 附加到常值,會強制其成為 Single 資料類型。Appending the literal type character F to a literal forces it to the Single data type. 將識別項類型字元 ! 附加到任何識別項,會強制其成為 SingleAppending the identifier type character ! to any identifier forces it to Single.

  • Framework 型別。Framework Type. 在 .NET Framework 中對應的類型為 System.Single 結構。The corresponding type in the .NET Framework is the System.Single structure.

另請參閱See also