Table of Contents

Enum RoundOffAccuracy

Namespace
Cuemon.Extensions
Assembly
Cuemon.Extensions.Core.dll

The accuracy of a rounding for a computed number.

public enum RoundOffAccuracy
Extension Methods

Fields

NearestHundredThousandth = 100000

Specifies a rounding to the nearest hundred thousandth of a number.

NearestHundredth = 100

Specifies a rounding to the nearest hundredth of a number.

NearestMillion = 1000000

Specifies a rounding to the nearest million of a number.

NearestTenThousandth = 10000

Specifies a rounding to the nearest ten thousandth of a number.

NearestTenth = 10

Specifies a rounding to the nearest tenth of a number.

NearestThousandth = 1000

Specifies a rounding to the nearest thousandth of a number.

Examples

The following example demonstrates how to use the enum with the extension method to round double values to the nearest specified accuracy.

using System;
using Cuemon.Extensions;

namespace MyApp.Examples;

public static class RoundOffAccuracyExample
{
    public static void Demonstrate()
    {
        double value = 123456789.987654321d;

        Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestTenth));
        Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestHundredth));
        Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestThousandth));
        Console.WriteLine(value.RoundOff(RoundOffAccuracy.NearestMillion));
    }
}