In this article:

General Information

Description

Example

Using Maximum and Minimum Values of System Types

Article number: KB000007

General Information

Related blocks:

Description

When analyzing application code it was found that custom values are used to mark limits of minimum value. This may lead to getting wrong results when executing a function similar to the function described below:

Public Function min_r(q: Array Of Double): Variant;
Var
    min: Double;
    i: Integer;
Begin
    min := -99999999;
    For i := 0 To q.Length - 1 Do
        If q[i] > min Then
            min := q[i];
        End If;
    End For;
    Return min;
End Function min_r;

Use the MinValue and MaxValue properties to get minimum or maximum values for various types of data:

Minimum value of data type Maximum value of data type
Currency Currency
DateTime DateTime
Decimal Decimal
Double Double
Integer Integer
TimeSpan TimeSpan

Example

Correct method of specifying limits of the minimum value:

Public Function min_r(q: Array Of Double): Variant;
Var
    min: Double;
    i: Integer;
Begin
    min := Double.MinValue;
    For i := 0 To q.Length - 1 Do
        If q[i] > min Then
            min := q[i];
        End If;
    End For;
    Return min;
End Function min_r;

See also:

Developers Knowledge Base