System.Math.SimpleRoundTo
Delphi
function SimpleRoundTo(const AValue: Single; const ADigit: TRoundToRange = -2): Single;
function SimpleRoundTo(const AValue: Double; const ADigit: TRoundToRange = -2): Double;
function SimpleRoundTo(const AValue: Extended; const ADigit: TRoundToRange = -2): Extended;
C++
extern DELPHI_PACKAGE float __fastcall SimpleRoundTo(const float AValue, const TRoundToRange ADigit = (TRoundToRange)(0xfffffffe))/* overload */;
Properties
Type | Visibility | Source | Unit | Parent |
---|---|---|---|---|
function | public | System.Math.pas System.Math.hpp |
System.Math | System.Math |
Description
Rounds a floating-point value to a specified digit or power of ten using symmetric arithmetic rounding.
Call SimpleRoundTo to round AValue
to a specified power of ten.
ADigit
indicates the power of ten to which you want AValue
rounded. It can be any value in the range from –37 through 37.
SimpleRoundTo returns the nearest value that has the specified power of ten. In case AValue
is exactly in the middle of the two nearest values that have the specified power of ten (above and below), this function returns:
- The value toward plus infinity if
AValue
is positive. - The value toward minus infinity if
AValue
is negative and the FPU rounding mode is not set tormUp
.
Note: The result of this function depends on the current FPU rounding mode. You can change the FPU rounding mode using the SetRoundMode function.
The following examples illustrate the results of SimpleRoundTo:
Expression |
Value |
---|---|
|
1235000 |
|
1.23 |
|
1.24 |
|
-1.23 or -1.24 (depending on the current FPU rounding mode) |
To round in "Banker's mode", use System.Math.RoundTo.
See Also