A division problem
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Mar 24 14:22:39 PDT 2014
On 3/24/14, 2:51 AM, Don wrote:
> It is indeed a common floating-point bug.
>
> I came up with a solution for this a couple of years ago, never got
> around to doing a pull request, but it's on the newsgroup somewhere.
> It's a little extension to the range propagation implementation. You add
> a boolean flag to the range, which indicates 'a fractional part has been
> discarded'. This flag gets set whenever you perform an integer division
> (or integer exponentiation with a negative power), and is cleared
> whenever there is a cast or a bitwise operation.
>
> Then, disallow implicit casting from integer to floating point whenever
> the fractional bit is set. Catches all these kinds of bugs, doesn't
> require any changes to the language.
That seems a sensible thing to do. I've assigned
https://d.puremagic.com/issues/show_bug.cgi?id=12452 to you for now.
Andrei
More information about the Digitalmars-d
mailing list