Can we drop cast from float to int ?

Jesse Phillips jessekphillips+D at gmail.com
Mon Mar 22 21:22:39 PDT 2010


#ponce wrote:

> 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 ? Or even undefined, depending on the rounding mode ? I just asked to 3 fellow programmers, it seems like i'm not the onlyone to find this confusing.
>
> Why should a destructive cast should be _that_ implicit anyway ?

I've never considered anything but truncate.

Also how is it implicit?



More information about the Digitalmars-d mailing list