Detecting inadvertent use of integer division
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Dec 15 08:59:46 PST 2009
Walter Bright wrote:
> Don wrote:
>> Integer expressions remain inexact until there's a cast.
>>
>> (It's very simple to implement, you just use the integer range code,
>> adding an 'inexact' flag. Division sets the flag, casts clear the
>> flag, everything else just propagates it if a unary operation, or ORs
>> the two flags if a binary operation).
>
> That sounds like a very good idea.
I think the same (though I personally am not liable because it's been
burned in my brain to always add ".0" to FP-involved literals). It's an
improvement in the same vein as value range propagation.
Should we make this part of the language, or as a quality of
implementation issue? I prefer the former, because the latter means that
code compiles on one machine and doesn't on another.
Andrei
More information about the Digitalmars-d
mailing list