PeterO.Numbers.ERounding

## PeterO.Numbers.ERounding

public sealed struct ERounding :
    System.Enum,
    System.IComparable,
    System.IConvertible,
    System.IFormattable

Specifies the mode to use when “shortening” numbers that otherwise can’t fit a given number of digits, so that the shortened number has about the same value. This “shortening” is known as rounding. (The “E” stands for “extended”, and has this prefix to group it with the other classes common to this library, particularly EDecimal, EFloat, and ERational.).

Member Summary

### Ceiling

public static PeterO.Numbers.ERounding Ceiling = 6;

If there is a fractional part, the number is rounded to the highest representable number that’s closest to it.

### Down

public static PeterO.Numbers.ERounding Down = 2;

The fractional part is discarded (the number is truncated).

### Floor

public static PeterO.Numbers.ERounding Floor = 7;

If there is a fractional part, the number is rounded to the lowest representable number that’s closest to it.

### HalfDown

public static PeterO.Numbers.ERounding HalfDown = 4;

Rounded to the nearest number; if the fractional part is exactly half, it is discarded.

### HalfEven

public static PeterO.Numbers.ERounding HalfEven = 5;

Rounded to the nearest number; if the fractional part is exactly half, the number is rounded to the closest representable number that is even. This is sometimes also known as “banker’s rounding”.

### HalfUp

public static PeterO.Numbers.ERounding HalfUp = 3;

Rounded to the nearest number; if the fractional part is exactly half, the number is rounded to the closest representable number away from zero. This is the most familiar rounding mode for many people.

### None

public static PeterO.Numbers.ERounding None = 0;

Indicates that rounding will not be used. If rounding to an inexact value is required, the rounding operation will report an error.

### Odd

public static PeterO.Numbers.ERounding Odd = 8;

Deprecated. Consider using ERounding.OddOrZeroFiveUp instead.

If there is a fractional part and the whole number part is even, the number is rounded to the closest representable odd number away from zero.

### OddOrZeroFiveUp

public static PeterO.Numbers.ERounding OddOrZeroFiveUp = 10;

For binary floating point numbers, this is the same as Odd. For other bases (including decimal numbers), this is the same as ZeroFiveUp. This rounding mode is useful for rounding intermediate results at a slightly higher precision (at least 2 bits more for binary) than the final precision.

### Up

public static PeterO.Numbers.ERounding Up = 1;

If there is a fractional part, the number is rounded to the closest representable number away from zero.

### ZeroFiveUp

public static PeterO.Numbers.ERounding ZeroFiveUp = 9;

Deprecated. Use ERounding.OddOrZeroFiveUp instead.

If there is a fractional part and if the last digit before rounding is 0 or half the radix, the number is rounded to the closest representable number away from zero; otherwise the fractional part is discarded. In overflow, the fractional part is always discarded.

Back to Numbers start page.