Please enable JavaScript to view this site.

Codolex

The rounding activities can be used to round numerical values into integers or specified decimals

 

Rounding

Activity properties

 

Possible rounding options

 

Ceil

Rounds up to an integer.

 

Example:

DecimalValue = 3.3

 

begin

var RoundingValue: Integer;

 RoundingValue := Ceil(DecimalValue);

end;

Result = 4

 

Floor

Rounds down to an integer.

 

Example:

DecimalValue = 3.3

 

begin

var RoundingValue: Integer;

 RoundingValue := Floor(DecimalValue);

end;

Result = 3

 

Fraction parts

Returns the part after the ',' from a decimal.

 

Example:

DecimalValue = 3.3

 

begin

var RoundingValue: Integer;

 RoundingValue := Frac(DecimalValue);

end;

Result = 0.3

 

round to tens

Rounds a floating-point value to a specified power of ten.

The 'Digits to round' will be a positive integer in the RoundTo function.

 

Example:

DecimalValue = 1234.1234

Digets to round = 2

 

begin

var RoundingValue: Double;

 RoundingValue := RoundTo(DecimalValue, 2);

end;

Result = 1200

 

Round to decimals

Rounds a floating-point value to a specified digit.

The 'Digits to round' will be a negative integer in the RoundTo function

 

Example:

DecimalValue = 1234.1234

Digits to round = 2

 

begin

var RoundingValue: Double;

 RoundingValue := RoundTo(DecimalValue, 2);

end;

Result = 1234.12

 

Trunc

Drops everething behind the ',' part of a decimal without rounding.

 

Example:

DecimalValue = -3.56

begin

var RoundingValue: Double;

 RoundingValue := Trunc(DecimalValue);

end;

Result = -3

 

Integer part

Returns the part before the ',' from a decimal.

 

Example:

DecimalValue = 3.6

 

begin

var RoundingValue: Double;

 RoundingValue := Trunc(DecimalValue);

end;

Result = -3

 

 

 

© by GDK Software