D do not know which function to use apparently

Andrea Fontana nospam at example.org
Tue Dec 11 15:42:33 UTC 2018


On Tuesday, 11 December 2018 at 15:17:10 UTC, Narxa wrote:
> Yes, it worked:
> ---------------
> int var = cast(int) floor(sqrt( cast(float) n ));
>
>
> I thought floor already returned an 'int' but I was mistaken.
>
> Thank you very much.

I think you don't need floor.

int var = cast(int)(sqrt(cast(float)n));

or:

int var = cast(int)(float(i).sqrt);

or:

int var = float(i).sqrt.to!int;

Andrea


More information about the Digitalmars-d-learn mailing list