rounded - multiple declarations

Function rounded

Returns a point whose coordinates are rounded to the nearest integral-valued floating-point values.

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

This operation is available only for floating-point geometry.

Halfway cases are rounded away from zero. NaN and infinities remain non-finite floating-point values; signed zero is preserved.

The scalar type is unchanged. This operation does not convert the result to an integral geometry type.

No allocation is performed.

Complexity

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

Function rounded

Returns a vector whose components are rounded to the nearest integral-valued floating-point values.

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

This operation is available only for floating-point geometry.

Halfway cases are rounded away from zero. NaN and infinities remain non-finite floating-point values; signed zero is preserved.

The scalar type is unchanged. This operation does not convert the result to an integral geometry type.

No allocation is performed.

Complexity

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

Example

Example rounding halfway values away from zero.

import geo;

const point =
    Point2!double(
        1.5,
        -2.5
    );

const vector =
    Vector2!double(
        -0.5,
        3.5
    );

assert(
    point.rounded ==
    Point2!double(
        2.0,
        -3.0
    )
);

assert(
    vector.rounded ==
    Vector2!double(
        -1.0,
        4.0
    )
);