Always false float comparisons

Marco Leise via Digitalmars-d digitalmars-d at puremagic.com
Thu May 12 16:10:39 PDT 2016


Am Thu, 12 May 2016 08:55:52 -0700
schrieb Walter Bright <newshound2 at digitalmars.com>:

> On 5/12/2016 3:30 AM, Manu via Digitalmars-d wrote:
> > If you're set on a warning, at least make the warning recommend
> > down-casting the higher precision term to the lower precision?  
> 
> Yes, of course. I believe error messages should suggest corrective action.

Because of afore mentioned difference between cast(float)1.30
and 1.30f, the correct action for the original case is to
suffix the literal with 'f'. That gives you the correct number
to compare to.

-- 
Marco



More information about the Digitalmars-d mailing list