Use the Min method to return and display the smaller of two Single variables. : Math « Development « VB.Net Tutorial






Class Sample
   Public Shared Sub Main()
      Dim nl As String = Environment.NewLine

      Dim xByte1 As Byte = 1
      Dim xByte2 As Byte = 51
      Dim xShort1 As Short = - 2
      Dim xShort2 As Short = 52
      Dim xInt1 As Integer = - 3
      Dim xInt2 As Integer = 53
      Dim xLong1 As Long = - 4
      Dim xLong2 As Long = 54
      Dim xSingle1 As Single = 5F
      Dim xSingle2 As Single = 55F
      Dim xDouble1 As Double = 6.0
      Dim xDouble2 As Double = 56.0
      Dim xDecimal1 As [Decimal] = 7D
      Dim xDecimal2 As [Decimal] = 57D

      ' The following types are not CLS-compliant.
      Dim xSbyte1 As SByte = 101
      Dim xSbyte2 As SByte = 111
      Dim xUshort1 As UShort = 102
      Dim xUshort2 As UShort = 112
      Dim xUint1 As UInteger = 103
      Dim xUint2 As UInteger = 113
      Dim xUlong1 As ULong = 104
      Dim xUlong2 As ULong = 114

      Console.WriteLine(Math.Min(xByte1, xByte2))
      Console.WriteLine(Math.Min(xShort1, xShort2))
      Console.WriteLine(Math.Min(xInt1, xInt2))
      Console.WriteLine(Math.Min(xLong1, xLong2))
      Console.WriteLine(Math.Min(xSingle1, xSingle2))
      Console.WriteLine(Math.Min(xDouble1, xDouble2))
      Console.WriteLine(Math.Min(xDecimal1, xDecimal2))
      Console.WriteLine(Math.Min(xSbyte1, xSbyte2))
      Console.WriteLine(Math.Min(xUshort1, xUshort2))
      Console.WriteLine(Math.Min(xUInt1, xUInt2))
      Console.WriteLine(Math.Min(xUlong1, xUlong2))
   End Sub
End Class








7.15.Math
7.15.1.Math.Sqrt and Atan2
7.15.2.Math. Cos and Sin
7.15.3.Convert rectangular 3D coordinates to cylindrical coordinates.
7.15.4.Generating random integers.
7.15.5.Math.Round
7.15.6.Randomize
7.15.7.This example demonstrates Math.Max()
7.15.8.Use the Min method to return and display the smaller of two Single variables.