RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Math.SimpleRoundTo Function

Rounds a floating-point value to a specified digit or power of ten using asymmetric arithmetic rounding.

Pascal
function SimpleRoundTo(const AValue: Extended; const ADigit: TRoundToRange = -2): Extended;
C++
Extended SimpleRoundTo(const Extended AValue, const TRoundToRange ADigit = -2);

Call SimpleRoundTo to round AValue to a specified power of ten. 

AValue is the value to round. 

ADigit indicates the power of ten to which you want AValue rounded. It can be any value from –37 to 37 (inclusive). 

SimpleRoundTo uses asymmetric arithmetic rounding to determine how to round values that are exactly midway between the two values that have the desired number of significant digits. This method always rounds to the larger value. 

The following examples illustrate the use of SimpleRoundTo:

Expression 
Value 
SimpleRoundTo(1234567, 3)  
1234000  
SimpleRoundTo(1.234, -2)  
1.23  
SimpleRoundTo(1.235, -2)  
1.24  
SimpleRoundTo(-1.235, -2)  
-1.23  

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!