floored - multiple declarations

Function floored

Returns a point with each coordinate rounded toward negative infinity.

Point2!T floored(T)(
  Point2!T value
) pure nothrow @nogc @property @safe
if (isFloatingPoint!T);

This operation is available only for floating-point geometry and retains the original scalar type. Non-finite values follow the underlying floating-point floor semantics.

No allocation is performed.

Complexity

O(1) time and O(1) auxiliary space.

Function floored

Returns a vector with each component rounded toward negative infinity.

Vector2!T floored(T)(
  Vector2!T value
) pure nothrow @nogc @property @safe
if (isFloatingPoint!T);

This operation is available only for floating-point geometry and retains the original scalar type. Non-finite values follow the underlying floating-point floor semantics.

No allocation is performed.

Complexity

O(1) time and O(1) auxiliary space.

Example

Example rounding coordinates toward negative infinity.

import geo;

const point =
    Point2!double(
        1.75,
        -2.25
    );

const vector =
    Vector2!double(
        -1.25,
        2.75
    );

assert(
    point.floored ==
    Point2!double(
        1.0,
        -3.0
    )
);

assert(
    vector.floored ==
    Vector2!double(
        -2.0,
        2.0
    )
);