Enums

enum RoundingMode

public enum RoundingMode <: Equatable<RoundingMode> & ToString {
    | Ceiling
    | Down
    | Floor
    | HalfEven
    | HalfUp
    | Up
}

Description: Specifies the enumeration class of rounding rules, including six rounding rules. In addition to the five rounding rules of floating-point numbers specified in IEEE 754, the most commonly used rounding off rule is provided.

Decimal numberUpDownCeilingFloorHalfUpHalfEven
7.5878788
4.5545454
-1.1-2-1-1-2-1-1
-4.5-5-4-4-5-5-4
-7.5-8-7-7-8-8-8

Parent types:

Ceiling

Ceiling

Description: Rounds towards positive infinity.

Down

Down

Description: Rounds towards zero.

Floor

Floor

Description: Rounds towards negative infinity.

HalfEven

HalfEven

Description: Rounds a number using the rounding half to even method, which is also called "banker's rounding".

HalfUp

HalfUp

Description: Rounds off a number.

Up

Up

Description: Rounds away from zero.

func toString()

public func toString(): String

Description: Generates a rounding rule name string.

Returns:

  • String: rounding rule name string

operator func ==(RoundingMode)

public operator func ==(that: RoundingMode): Bool

Description: Checks whether rounding rules are the same.

Parameters:

Returns:

  • Bool: If the rounding rules are the same, true is returned. Otherwise, false is returned.