Can we drop cast from float to int ?

Lionello Lunesu lio at lunesu.remove.com
Mon Mar 22 19:12:05 PDT 2010


On 23-3-2010 7:59, Trass3r 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 ?
> 
> I've never heard anything else but truncate. Rounding can thus be done
> with cast(int)(f + 0.5f).

or -0.5f when f < 0.0



More information about the Digitalmars-d mailing list