IFloatingPoint<TSelf>.Round Method

Definition

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Overloads

Round(TSelf)

Rounds a value to the nearest integer using the default rounding mode (ToEven).

Round(TSelf, Int32)

Rounds a value to a specified number of fractional-digits using the default rounding mode (ToEven).

Round(TSelf, MidpointRounding)

Rounds a value to the nearest integer using the specified rounding mode.

Round(TSelf, Int32, MidpointRounding)

Rounds a value to a specified number of fractional digits using the specified rounding mode.

Round(TSelf)

Source:
IFloatingPoint.cs
Source:
IFloatingPoint.cs
Source:
IFloatingPoint.cs

Rounds a value to the nearest integer using the default rounding mode (ToEven).

C#
public static virtual TSelf Round(TSelf x);

Parameters

x
TSelf

The value to round.

Returns

TSelf

The result of rounding x to the nearest integer using the default rounding mode.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10

Round(TSelf, Int32)

Source:
IFloatingPoint.cs
Source:
IFloatingPoint.cs
Source:
IFloatingPoint.cs

Rounds a value to a specified number of fractional-digits using the default rounding mode (ToEven).

C#
public static virtual TSelf Round(TSelf x, int digits);

Parameters

x
TSelf

The value to round.

digits
Int32

The number of fractional digits to which x should be rounded.

Returns

TSelf

The result of rounding x to digits fractional-digits using the default rounding mode.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10

Round(TSelf, MidpointRounding)

Source:
IFloatingPoint.cs
Source:
IFloatingPoint.cs
Source:
IFloatingPoint.cs

Rounds a value to the nearest integer using the specified rounding mode.

C#
public static virtual TSelf Round(TSelf x, MidpointRounding mode);

Parameters

x
TSelf

The value to round.

mode
MidpointRounding

The mode under which x should be rounded.

Returns

TSelf

The result of rounding x to the nearest integer using mode.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10

Round(TSelf, Int32, MidpointRounding)

Source:
IFloatingPoint.cs
Source:
IFloatingPoint.cs
Source:
IFloatingPoint.cs

Rounds a value to a specified number of fractional digits using the specified rounding mode.

C#
public static abstract TSelf Round(TSelf x, int digits, MidpointRounding mode);

Parameters

x
TSelf

The value to round.

digits
Int32

The number of fractional digits to which x should be rounded.

mode
MidpointRounding

The mode under which x should be rounded.

Returns

TSelf

The result of rounding x to digits fractional-digits using mode.

Applies to

.NET 10 and other versions
Product Versions
.NET 7, 8, 9, 10