deebug

Util.Calc.vb

Jul 12th, 2011
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Namespace Sitesource.Util
  2.     ''' <summary>
  3.    ''' Yes I'm aware that there MUST be a lot of better ways than this, but for now this works.
  4.    ''' </summary>
  5.    ''' <remarks></remarks>
  6.    Public Class Calc
  7.         ''' <summary>
  8.        ''' Get max of a series of numbers
  9.        ''' </summary>
  10.        ''' <param name="values"></param>
  11.        ''' <returns></returns>
  12.        ''' <remarks></remarks>
  13.        Public Shared Function Max(ByVal ParamArray values() As Decimal) As Decimal
  14.             If values.Length < 1 Then Throw New ArgumentNullException
  15.             Dim _max As Decimal = Decimal.MinValue
  16.             For Each value As Decimal In values
  17.                 _max = Math.Max(_max, value)
  18.             Next
  19.             Return _max
  20.         End Function
  21.         ''' <summary>
  22.        ''' Get max of a series of numbers
  23.        ''' </summary>
  24.        ''' <param name="values"></param>
  25.        ''' <returns></returns>
  26.        ''' <remarks></remarks>
  27.        Public Shared Function Min(ByVal ParamArray values() As Decimal) As Decimal
  28.             If values.Length < 1 Then Throw New ArgumentNullException
  29.             Dim _min As Decimal = Decimal.MaxValue
  30.             For Each value As Decimal In values
  31.                 _min = Math.Min(_min, value)
  32.             Next
  33.             Return _min
  34.         End Function
  35.     End Class
  36. End Namespace
Advertisement
Add Comment
Please, Sign In to add comment