Show / Hide Table of Contents

    Enum NppRoundMode

    Rounding Modes

    The enumerated rounding modes are used by a large number of NPP primitives to allow the user to specify the method by which fractional values are converted to integer values. Also see \ref rounding_modes.

    For NPP release 5.5 new names for the three rounding modes are introduced that are based on the naming conventions for rounding modes set forth in the IEEE-754 floating-point standard. Developers are encouraged to use the new, longer names to be future proof as the legacy names will be deprecated in subsequent NPP releases.

    Namespace: ManagedCuda.NPP
    Assembly: NPP.dll
    Syntax
    public enum NppRoundMode

    Fields

    Name Description
    Financial

    Round according to financial rule.

    All fractional numbers are rounded to their nearest integer. The ambiguous cases (i.e. integer.5) are rounded away from zero.

    E.g.

    • roundFinancial(0.4) = 0

    • roundFinancial(0.5) = 1

    • roundFinancial(-1.5) = -2

    Near

    Round to the nearest even integer.

    All fractional numbers are rounded to their nearest integer. The ambiguous cases (i.e. integer.5) are rounded to the closest even integer.

    E.g.

    • roundNear(0.5) = 0

    • roundNear(0.6) = 1

    • roundNear(1.5) = 2

    • roundNear(-1.5) = -2

    RoundNearestTiesAwayFromZero

    Round according to financial rule.

    All fractional numbers are rounded to their nearest integer. The ambiguous cases (i.e. integer.5) are rounded away from zero.

    E.g.

    • roundFinancial(0.4) = 0

    • roundFinancial(0.5) = 1

    • roundFinancial(-1.5) = -2

    RoundNearestTiesToEven

    Round to the nearest even integer.

    All fractional numbers are rounded to their nearest integer. The ambiguous cases (i.e. integer.5) are rounded to the closest even integer.

    E.g.

    • roundNear(0.5) = 0

    • roundNear(0.6) = 1

    • roundNear(1.5) = 2

    • roundNear(-1.5) = -2

    RoundTowardZero

    Round towards zero (truncation).

    All fractional numbers of the form integer.decimals are truncated to integer.

    • roundZero(1.5) = 1

    • roundZero(1.9) = 1

    • roundZero(-2.5) = -2

    Zero

    Round towards zero (truncation).

    All fractional numbers of the form integer.decimals are truncated to integer.

    • roundZero(1.5) = 1

    • roundZero(1.9) = 1

    • roundZero(-2.5) = -2

    • Improve this Doc
    • View Source
    Back to top Generated by DocFX