Instance Property

hexDigitValue

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

Declaration

var hexDigitValue: Int? { get }

Discussion

Hexadecimal digits include 0-9, Latin letters a-f and A-F, and their fullwidth compatibility forms. If the character does not represent a hexadecimal digit, the value of this property is nil.

let chars: [Character] = ["1", "a", "F", "g"]
for ch in chars {
    print(ch, "-->", ch.hexDigitValue)
}
// 1 --> 1
// a --> 10
// F --> 15
// g --> 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 wholeNumberValue: Int?

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

var isHexDigit: Bool

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