Instance Property

wholeNumberValue

The numeric value this character represents, if it represents a whole number.

Declaration

var wholeNumberValue: Int? { get }

Discussion

If this character does not represent a whole number, or the value is too large to represent as an Int, the value of this property is nil.

let chars: [Character] = ["4", "④", "万", "a"]
for ch in chars {
    print(ch, "-->", ch.properties.numericValue)
}
// 4 --> 4
// ④ --> 4
// 万 --> 10000
// a --> nil

See Also

Checking a Character’s Numeric Properties

var isNumber: Bool

A Boolean value indicating whether this character represents a number.

var isWholeNumber: Bool

A Boolean value indicating whether this character represents a whole number.

var isHexDigit: Bool

A Boolean value indicating whether this character represents a hexadecimal digit.

var hexDigitValue: Int?

The numeric value this character represents, if it is a hexadecimal digit.