Compartilhar via


Como: Armazenar o máximo de dígitos significativos em uma variável (Visual Basic)

A variable holds numbers with fractions if you declare it to be of data type Decimal.

A variable of the Tipo de dados decimais (Visual Basic) can hold numbers with 29 significant digits, including as many as 28 decimal places.

Performance. Decimal is the least efficient of the numeric data types. If you do not need the full precision of the Decimal data type, you can use the Double data type, which can hold as many as 18 significant digits. Operations with Double are faster than with Decimal, and Double variables take up less space in memory. For more information on Double, see Como: Armazenar frações em uma variável (Visual Basic).

You should weigh the importance of precision against performance before choosing a data type.

Larger Magnitude. Se você precisar de sua variável para manter os números de maior magnitude que o Decimal tipo de dados pode comportar, você pode usar o Double ou Single tipo de dados, cada um deles com um intervalo maior. While Decimal variables can hold values up to 7.9228162514264337593543950335E+28, Single variables can hold up to 3.4028235E+38, and Double variables can hold up to 1.79769313486231570E+308.

To hold the most significant digits in a variable

  1. Declare the variable with a Instrução Dim (Visual Basic).

  2. Follow the variable name with an As clause.

  3. Follow the As keyword with the Decimal keyword.

Consulte também

Referência

Resumo de tipo de dados (Visual Basic)

Tipo de dados decimais (Visual Basic)

Tipo de dados duplo (Visual Basic)

Conceitos

Caracteres de tipo (Visual Basic)

Outros recursos

Tipos de dados elementares (Visual Basic)