Increment​Number​Rounder Increment​Number​Rounder Increment​Number​Rounder Class

Definition

Rounds numbers to a specified increment.

For example, this class can be used to round a number to the nearest 0.01.

public : sealed class IncrementNumberRounder : IIncrementNumberRounder, INumberRounderpublic sealed class IncrementNumberRounder : IIncrementNumberRounder, INumberRounderPublic NotInheritable Class IncrementNumberRounder Implements IIncrementNumberRounder, INumberRounder
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Constructors

IncrementNumberRounder() IncrementNumberRounder() IncrementNumberRounder()

Creates an IncrementNumberRounder object.

This constructor initializes RoundingAlgorithm to a default value of RoundingAlgorithm.**RoundHalfUp**, and Increment to 1.

public : IncrementNumberRounder()public IncrementNumberRounder()Public Sub New()
Attributes

Properties

Increment Increment Increment

Gets or sets the increment this IncrementNumberRounder object uses for rounding.

public : double Increment { get; set; }public double Increment { get; set; }Public ReadWrite Property Increment As double
Value
double double double

The increment used for rounding.

Attributes

Remarks

This property can be one of the following:

  • An integer greater than 0.
  • A fraction of the form 1/n, where n is an integer between 2 and 10000000000, inclusive.
  • 1.0e-11, 1.0e-12, 1.0e-13, 1.0e-14, 1.0e-15, 1.0e-16, 1.0e-17, 1.0e-18, 1.0e-19, or 1.0e-20.

This property is initialized to a default value of 1.

When rounding is performed, the result is produced in this manner:

  1. Divide the input by the Increment.
  2. Round the result to an integer using the rounding strategy of RoundingAlgorithm.
  3. Multiply the result by the Increment.

RoundingAlgorithm RoundingAlgorithm RoundingAlgorithm

Gets or sets the rounding strategy value for this IncrementNumberRounder object.

public : RoundingAlgorithm RoundingAlgorithm { get; set; }public RoundingAlgorithm RoundingAlgorithm { get; set; }Public ReadWrite Property RoundingAlgorithm As RoundingAlgorithm
Attributes

Remarks

This property is initialized to a default value of RoundingAlgorithm.**RoundHalfUp**.

Methods

RoundDouble(Double) RoundDouble(Double) RoundDouble(Double)

Rounds a Double number to the specified increment.

public : double RoundDouble(double value)public double RoundDouble(Double value)Public Function RoundDouble(value As Double) As double
Parameters
value
double Double Double

The Double value to be rounded.

Returns
double double double

The rounded number. This result is a double precision floating point number, which is not necessarily an integer.

Attributes

Remarks

The rounding strategy is based on the values of Increment and RoundingAlgorithm.

Note

This method is precise only within the limits of the Double data type: approximately 15 digits.

RoundInt32(Int32) RoundInt32(Int32) RoundInt32(Int32)

Rounds an Int32 number to the specified increment.

public : int RoundInt32(int value)public int RoundInt32(Int32 value)Public Function RoundInt32(value As Int32) As int
Parameters
value
int Int32 Int32

The Int32 value to be rounded.

Returns
int int int

The rounded 32 bit integer.

Attributes

Remarks

The rounding strategy is based on the values of Increment and RoundingAlgorithm.

RoundInt64(Int64) RoundInt64(Int64) RoundInt64(Int64)

Rounds an Int64 number to the specified increment.

public : long RoundInt64(long value)public long RoundInt64(Int64 value)Public Function RoundInt64(value As Int64) As long
Parameters
value
long Int64 Int64

The Int64 value to be rounded.

Returns
long long long

The rounded 64 bit integer.

Attributes

Remarks

The rounding strategy is based on the values of Increment and RoundingAlgorithm.

RoundSingle(Single) RoundSingle(Single) RoundSingle(Single)

Rounds a Single number to the specified increment.

public : float RoundSingle(float value)public float RoundSingle(Single value)Public Function RoundSingle(value As Single) As float
Parameters
value
float Single Single

The Single value to be rounded.

Returns
float float float

The rounded number. This result is a single precision floating point number, which is not necessarily an integer.

Attributes

Remarks

The rounding strategy is based on the values of Increment and RoundingAlgorithm.

Note

This method is precise only within the limits of the Single data type: approximately 7 digits.

RoundUInt32(UInt32) RoundUInt32(UInt32) RoundUInt32(UInt32)

Rounds a UInt32 number to the specified increment.

public : unsigned short RoundUInt32(unsigned int value)public uint RoundUInt32(UInt32 value)Public Function RoundUInt32(value As UInt32) As uint
Parameters
value
unsigned int UInt32 UInt32

The UInt32 value to be rounded.

Returns
unsigned short uint uint

The rounded unsigned 32 bit integer.

Attributes

Remarks

The rounding strategy is based on the values of Increment and RoundingAlgorithm.

RoundUInt64(UInt64) RoundUInt64(UInt64) RoundUInt64(UInt64)

Rounds a UInt64 number to the specified increment.

public : ulong RoundUInt64(unsigned __int64 value)public ulong RoundUInt64(UInt64 value)Public Function RoundUInt64(value As UInt64) As ulong
Parameters
value
unsigned __int64 UInt64 UInt64

The UInt64 value to be rounded.

Returns
ulong ulong ulong

The rounded unsigned 64 bit integer.

Attributes

Remarks

The rounding strategy is based on the values of Increment and RoundingAlgorithm.

See Also