View Issue Details
ID  Project  Category  View Status  Date Submitted  Last Update 

0033805  FPC  Documentation  public  20180530 13:36  20180628 10:38 
Reporter  Wolfgang Ehrhardt  Assigned To  Michael Van Canneyt  
Priority  normal  Severity  minor  Reproducibility  N/A 
Status  resolved  Resolution  fixed  
Product Version  Product Build  
Target Version  3.2.0  Fixed in Version  3.1.1  
Summary  0033805: Misleading documentation for TFPURoundingMode  
Description  The docmentation for TFPURoundingMode in https://www.freepascal.org/docshtml/rtl/system/tfpuroundingmode.html is misleading. The TFPURoundingMode enumerates the FPU Rounding modes, which is applied to all nonexact floatingpoint operation. The current description describes only the special case when used with the round function. type TFPURoundingMode = ( rmNearest, Round to nearest integer rmDown, Round to biggest integer smaller than value. rmUp, Round to smallest integer larger than value rmTruncate Cut off fractional part ); The Delphi6 Help rmNearest Rounds to the closest value. rmDown Rounds toward negative infinity. rmUp Rounds toward positive infinity. rmTruncate Truncates the value, rounding positive numbers down and negative numbers up. and Wikipedia (https://en.wikipedia.org/wiki/IEEE_floating_point#Rounding_rules) are more exact So I suggest to use something like this type TFPURoundingMode = ( rmNearest, Rounding to nearesteven (least significant 0 in case of a tie) rmDown, Rounding towards negative infinity (also known as rounding down). rmUp, Rounding towards positive infinity (also known as rounding up). rmTruncate Rounding towards zero (also known as truncation). );  
Additional Information  This issue report comes from http://www.lazarusforum.de/viewtopic.php?p=103793#p103793 ff.  
Tags  No tags attached.  
Fixed in Revision  1489  
FPCOldBugId  
FPCTarget  
Attached Files 


Sorry, but what is a "tie" here? Certainly not the thing which I don't like being wrapped around my neck. Please avoid such special words not known to the average programmer in a documentation article. 

See https://en.wikipedia.org/wiki/Rounding#Rounding_to_the_nearest_integer: Rounding a number y to the nearest integer requires some tiebreaking rule for those cases when y is exactly halfway between two integers — that is, when the fraction part of y is exactly 0.5. or https://en.wikipedia.org/wiki/Rounding#Round_half_to_even The problem with these references is that they are also misleading, because they once again argue for the round function only, e.g. whether 0.5 or 1.5 should be rounded up or down. The FPU rounding controls applies to ALL operations and an exact description has to introduce some more exotic terms than tiebreaking, namely roundingbit. stickybit etc. See e.g. https://stackoverflow.com/questions/19146131/roundingfloatingpointnumbersafteradditionguardstickyandroundbits or https://stackoverflow.com/questions/45662113/guardroundstickybitsfloatingpoint?rq=1 or do a web search with sticky bit rounding So may be this is a bit better: type TFPURoundingMode = ( rmNearest, Rounding to nearesteven (round to even, i.e. the least significant bit will be 0, if the number falls midway between to floatingpoint numbers) rmDown, Rounding towards negative infinity (also known as rounding down). rmUp, Rounding towards positive infinity (also known as rounding up). rmTruncate Rounding towards zero (also known as truncation). ); 

i'm so confused. "rmNearest" does not follow common rule of rounding, so it should be explained more detailed. i'm agree with Wolfgang Ehrhardt, that documentation is misleading, even if it is satisfy the standard of rounding floating point numbers. 

Improved the wording for rmNearest and rmTruncate, making the use of banker's rounding explicit. 
Date Modified  Username  Field  Change 

20180530 13:36  Wolfgang Ehrhardt  New Issue  
20180530 13:36  Wolfgang Ehrhardt  Status  new => assigned 
20180530 13:36  Wolfgang Ehrhardt  Assigned To  => Michael Van Canneyt 
20180530 15:06  wp  Note Added: 0108590  
20180530 15:41  Wolfgang Ehrhardt  Note Added: 0108591  
20180530 15:42  Wolfgang Ehrhardt  Note Edited: 0108591  View Revisions 
20180530 15:47  Wolfgang Ehrhardt  Note Edited: 0108591  View Revisions 
20180530 21:13  Marģers  Note Added: 0108595  
20180628 10:38  Michael Van Canneyt  Fixed in Revision  => 1489 
20180628 10:38  Michael Van Canneyt  Note Added: 0109100  
20180628 10:38  Michael Van Canneyt  Status  assigned => resolved 
20180628 10:38  Michael Van Canneyt  Fixed in Version  => 3.1.1 
20180628 10:38  Michael Van Canneyt  Resolution  open => fixed 
20180628 10:38  Michael Van Canneyt  Target Version  => 3.2.0 