Experimenting with Numerical Data Types

To experiment with the intrinsic VB 2008 data types, create a new Console Application named BasicDataTypes. First of all, understand that the numerical types of .NET support MaxValue and MinValue properties that provide information regarding the range a given type can store. For example:

Sub Main()

Console.WriteLine("***** Fun with Data Types *****") Console.WriteLine("Max of Integer: {0}", Integer.MaxValue)

Console.WriteLine("Min of Integer: {0}", Integer.MinValue) Console.WriteLine("Max of Double: {0}", Double.MaxValue) Console.WriteLine("Min of Double: {0}", Double.MinValue) End Sub

In addition to the MinValue/MaxValue properties, a given numerical system type may define additional useful members. For example, the System.Double type allows you to obtain the values for epsilon and infinity (which may be of interest to those of you with a mathematical flare):

Console.WriteLine("Double.Epsilon: {0}", Double.Epsilon) Console.WriteLine("Double.PositiveInfinity: {0}", _

Double.PositiveInfinity) Console.WriteLine("Double.NegativeInfinity: {0}", _ Double.NegativeInfinity)

Was this article helpful?

0 0

Post a comment