Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General Discussion » View Thread |
Messages 11 to 15 of 15 total |
Rounding |
Mon, Apr 11 2011 12:47 PM | Permanent Link |
Rita Tipton | Thanks Chris longtime no see or am I visually impaired that much ?
Rita |
Mon, Apr 11 2011 1:22 PM | Permanent Link |
Rita Tipton | So what did Rita do she wrote her own rounding function.
function TfrmMain.RoundRita(x: Extended; d: Integer): Extended; var n: Extended; begin n := IntPower(10, d); x := x * n; Result := (Int(x) + Int(Frac(x) * 2)) / n; end; |
Mon, Apr 11 2011 2:19 PM | Permanent Link |
Fernando Dias Team Elevate | Rita,
Ah I see, you were talking about Delphi rounding, and I was answering thinking of DBISAM rounding. Delphi does 'Banker's rounding', and DBISAM does 'normal' rounding. So yeah, if you want to round using the Delphi RoundTo() and get the same results as you do with DBISAM Round() you have to provide your own rounding function. From DBISAM manual: "The ROUND function performs "normal" rounding where the number is rounded up if the fractional portion beyond the number of decimal places being rounded to is greater than or equal to 5 and down if the fractional portion is less than 5" However Delphi rounding uses "bankers rounding": "RoundTo uses "Banker's 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 rounds to an even number in the case that AValue is not nearer to either value." Anyway, no matter what method you use, the sum of rounded parcels is only by accident the same as rounding the sum of the same parcels. -- Fernando Dias [Team Elevate] |
Mon, Apr 11 2011 3:47 PM | Permanent Link |
Aage J. | For "rounding", you might be interested in some work from John Herbster - he posts often on embarcadero.public.delphi.non-technical. You can find his decimal rounding routines on CodeCentral: http://cc.embarcadero.com/Item/19421 -- Aage J. |
Tue, Apr 12 2011 3:03 AM | Permanent Link |
Chris Holland SEC Solutions Ltd. Team Elevate | Hi Rita,
I am hiding in the ODBC newsgroups mostly these days, being a .NET boy now Chris On 11/04/2011 17:47, Rita wrote: > Thanks Chris longtime no see or am I visually impaired that much ? > Rita > > > -- Chris Holland [Team Elevate] |
« Previous Page | Page 2 of 2 | |
Jump to Page: 1 2 |
This web page was last updated on Tuesday, May 7, 2024 at 06:25 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |