Re: Bug in Delphi SimpleRoundTo function?
- From: "John Herbster" <herb-sci1_AT_sbcglobal.net>
- Date: Fri, 3 Aug 2007 14:17:45 -0500
"James Miller" wrote
I am pretty sure that Delphi's Currency type
calculations also use bankers rounding. Is there
a compiler switch or something to make it use
simple rounding?
A good programmer should know that there is no such
thing as "simple rounding" -- by that, I mean a
rounding rule that most programmers can agree on.
At least "bankers rounding" is a rule that most
programmers can agree on.
That aside, when ordinary programmers get caught in
the trap of using floating *binary* point numbers,
to represent (fixed or floating) decimal fraction
numbers and have to do any kind of rounding, then
they stumble all over themselves.
The problem, of course, is that general decimal
fractions cannot be exactly represented as
floating binary point numbers. This leads to
problems deciding what the floating binary point
number is really supposed to represent in decimal
fraction terms. My DecimalRounding package that
Willem mentioned solves this problem.
However, as someone ready to step into retirement
who has for many years tried both to educate the
ignorant and to push for incorporating actual
fixed and floating decimal fraction into Delphi,
I am really disappointed that I am still reading
such ill informed discussion of this problem.
Rgds, JohnH
--
Support the movement to add floating and fixed
decimal fraction numbers to Delphi.
http://qc.borland.com/wc/qcmain.aspx?d=28022
DecimalRounding (JH1) -- allows you to do about
nine kinds of decimal rounding with floating
binary point numbers.
http://cc.codegear.com/Item.aspx?id=21909
IEEE Number Analyzer (project source code) -- a
program that will convert a decimal fraction
number into the nearest possible floating binary
point number (i.e. single, double, or extended)
http://cc.codegear.com/item.aspx?id=23631
ExactFloatToStr -- a function for converting a
floating binary point number to its exact
decimal fraction values in a ASCII string.
http://cc.codegear.com/Item.aspx?id=19421
.
- Follow-Ups:
- Re: Bug in Delphi SimpleRoundTo function?
- From: Trevor Toms
- Re: Bug in Delphi SimpleRoundTo function?
- From: Q Correll
- Re: Bug in Delphi SimpleRoundTo function?
- From: James Miller
- Re: Bug in Delphi SimpleRoundTo function?
- References:
- Bug in Delphi SimpleRoundTo function?
- From: Trevor Toms
- Re: Bug in Delphi SimpleRoundTo function?
- From: Ralf Jansen
- Re: Bug in Delphi SimpleRoundTo function?
- From: James Miller
- Bug in Delphi SimpleRoundTo function?
- Prev by Date: Re: Vista and Delphi 5
- Next by Date: Re: Bug in Delphi SimpleRoundTo function?
- Previous by thread: Re: Bug in Delphi SimpleRoundTo function?
- Next by thread: Re: Bug in Delphi SimpleRoundTo function?
- Index(es):
Relevant Pages
|