IMath.Round

Fore Syntax

Round(Value: Double; Precision: Integer): Double;

Fore.NET Syntax

Round(Value: double; Precision: integer): double;

Parameters

Value. Rounded real number.

Precision. The number of decimal places, to which a number must be rounded.

Description

The Round method returns the result of rounding a number to the specified number of decimal places.

Comments

Values of input parameters cannot be empty.

If the number of decimal places is greater than 0, the number is rounded to the specified decimal places after the decimal separator.

If the number of decimal places is equal to 0, the number is rounded to the nearest integer.

If the number of decimal places is less than 0. the number is rounded to the left of the decimal separator.

Fore Example

To execute the example, add a link to the MathFin system assembly.

Sub UserProc;
Var
    r1, r2, r3, r4: Double;
Begin
    r1 := Math.Round(2.15,1);
    Debug.WriteLine(r1);
    r2 := Math.Round(-50.55,-2);
    Debug.WriteLine(r2);
    r3 := Math.Round(21.5,-1);
    Debug.WriteLine(r3);
    r4 := Math.Round(-1.475,2);
    Debug.WriteLine(r4);
End Sub UserProc;

After executing the example the console window displays rounding results:

Fore.NET Example

The requirements and result of the Fore.NET example execution match with those in the Fore example.

Imports Prognoz.Platform.Interop.MathFin;

Public Shared Sub Main(Params: StartParams);
Var
    r1, r2, r3, r4: double;
    Math: MathClass = New MathClass();
Begin
    r1 := Math.Round(2.15,1);
    System.Diagnostics.Debug.WriteLine(r1);
    r2 := Math.Round(-50.55,-2);
    System.Diagnostics.Debug.WriteLine(r2);
    r3 := Math.Round(21.5,-1);
    System.Diagnostics.Debug.WriteLine(r3);
    r4 := Math.Round(-1.475,2);
    System.Diagnostics.Debug.WriteLine(r4);
End Sub;

See also:

IMath