To cast a uint to float to compute k/n, use to! or cast()?

Enjoys Math via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jan 29 15:48:19 PST 2016


I want to compute the points of a regular polygon in a loop:

float r = 1.0;

for (uint k=0; k < numVerts; k++) {
    vertlist ~= Vec2D(r * cos(k/n * 2 * PI), ...)
}

How do I make sure k/n is a float or double?


More information about the Digitalmars-d-learn mailing list