Can we drop cast from float to int ?

Trass3r un at known.com
Mon Mar 22 16:59:09 PDT 2010


> I never knew exactly what the float-to-int C cast is supposed to do.
>
> float f = whatever();
> int b = cast(int) f;
>
>
> Does it truncate, floor or round ?

I've never heard anything else but truncate. Rounding can thus be done  
with cast(int)(f + 0.5f).



More information about the Digitalmars-d mailing list