Detecting inadvertent use of integer division

Phil Deets pjdeets2 at gmail.com
Mon Dec 14 21:02:36 PST 2009


On Mon, 14 Dec 2009 04:57:26 -0500, Don <nospam at nospam.com> wrote:

> In the very rare cases where the result of an integer division was  
> actually intended to be stored in a float, an explicit cast would be  
> required. So you'd write:
> double y = cast(int)(1/x);

To me,

double y = cast(double)(1/x);

makes more sense. Why cast to int?



More information about the Digitalmars-d mailing list