SetRoundMode
From Lazarus wiki
Jump to navigationJump to search
│ Deutsch (de) │ English (en) │
With SetRoundMode you can set the type of rounding. This is required when calling Round (...).
Syntax:
function SetRoundMode(const RoundMode: TFPURoundingMode): TFPURoundingMode;
The following parameters are possible for RoundMode:
- rmNearest: Rounds to the nearest even integer (Banker's Rounding: 0.5 rounds down to 0; 1.5 rounds up to 2).
- rmDown: generally rounds to the next smaller integer.
- rmUp: generally rounds to the next largest integer.
- rmTruncate: cuts off the decimal places.
Warning: The setting of the RoundMode applies to all internal floating point calculations. In particular, it determines how numbers that cannot be represented exactly as single / double / extended values are to be rounded to the internal representation within the scope of the available bits. Therefore, the use of SetRoundMode for general rounding purposes is not recommended.