Difference between revisions of "SetRoundMode"

From Lazarus wiki
Jump to navigationJump to search
(English translation of German page)
 
m (Added warning template)
Line 14: Line 14:
 
* rmTruncate: cuts off the decimal places.
 
* 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.
+
{{Warning|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.}}
  
 
== See also ==
 
== See also ==

Revision as of 07:42, 19 January 2020

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-icon.png

Warning: 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.

See also