|
|
 |
|
|
|
|
|
|
|
|
Visual Basic 2008 9.0 .NET Examples and Ebook
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| To represent numbers with digits after the decimal separator : |
| Single 4 bytes ( 32-bit floating-point notation )
range : negative values : -3.4028235E+38 <-> -1.401298E-45
zero
positive values : +1.401298E-45 <-> +3.4028235E+38
Double 8 bytes ( 64-bit floating-point notation )
range : negative values : -1.7976931348623157E+308 <->
-4.94065645841247E-324
zero
positive values : +4.94065645841247E-324) <->
+1.7976931348623157E+308
Decimal 16 bytes ( 128-bit floating-point notation ( base 10 ) )
range ( without digits after the decimal separator ) :
-79228162514264337593543950335 <->
+79228162514264337593543950335
range ( with maximum 28 digits after the decimal separator ) :
-7.9228162514264337593543950335 <->
+7.9228162514264337593543950335
smallest values : -0.0000000000000000000000000001 ( -1E-28 ) and
+0.0000000000000000000000000001 ( +1E-28 ) |
| The E followed by a number is the technical and scientific notation for the exponent for base 10. 2E-3 for instance is 2 x 10^-3 or 0.002.
All floating-point notations ( and arithmetic's ) follow the IEEE 754 standard. |
| Module Example1
Sub Main()
Dim someDouble As Double = 1.5
Console.WriteLine(someDouble)
Console.ReadLine()
End Sub
End Module Download Broncode |
| Use Decimal when high precision and accuracy is needed, for instance in financial applications. Be aware of the performance overhead, Decimal is by far the slowest and memory consuming numeric datatype. When performance is important, use Double, which on current platforms leads to the best performance.
Line (1) illustrates how the decimal separator is a dot ( . ).
Which decimal separator symbol will be used on the console depends on the culture-info. With the above output I assume the decimal separator is a comma ( , ). |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|