RoundTo function
Prototype: |
function RoundTo(X: double; NumberOfDigits: integer): double; |
|
Description: |
The RoundTo function rounds the value X to the specified number of decimal places. |
|
Syntax: |
RoundTo(X,NumberOfDigits); / variable:= RoundTo(X,NumberOfDigits); |
|
Part |
Description |
|
variable |
A variable declared as double |
|
X |
The unrounded value as a double |
|
NumberOfDigits |
The desired number of decimal places in the result value |
|
Return value: |
Rounded value of the input value as double |
|
Note: From the version X6 Field-Map uses Round function with a positive parameter of decimal places to the right side and negative to the left side (SQL approach). On the other hand, for versions X5 and older Field-Map uses a negative parameter of decimal places to the right side and positive to the left side (Object Pascal approach) in function RoundTo.
Example:
var
v, MeanOfHeight_m:variant;
d :double;
i:integer;
begin
OpenLog('Round results');
MeanOfHeight_m:=Trees_2013.GetMeanOfAttributeValues('Height_m','');
log(format('MeanOfHeight_m: %3.6f',[Variant2Float(MeanOfHeight_m)])); log('');
v:= RoundVariant(MeanOfHeight_m, 2);
log(format('RoundVariant (MeanOfHeight_m, 2): %3.2f',[Variant2Float(v)]));
d:=RoundTo(Variant2Float(MeanOfHeight_m),-2);
log(format('RoundTo (MeanOfHeight_m,-2): %3.2f',[d]));
v:=Round(Variant2Float(MeanOfHeight_m),2);
log(format('Round (MeanOfHeight_m,2): %3.2f',[Variant2Float(v)]));
i:=Round2int(d);
log(format('Round2int (MeanOfHeight_m): %6d',[i]));
end.
See also:
Power; Round; RoundTo, RoundVariant; Round2int, Cos; ArcCos; ArcCosH; Sin; ArcSin; ArcSinH; ArcTan; ArcTan2; ArcTanH; CosH; SinH; Tan; TanH; Random; RandomRange; Randomize; Floor; Ceil; Int; Frac; Log10; Ln; Exp; Abs; Min; Max; Odd; SecondsBetween;CompareValue; SameValue; Trunc
© 2024 IFER-Monitoring and Mapping Solutions