---
title: hexDigitValue
framework: swift
role: symbol
role_heading: Instance Property
path: swift/character/hexdigitvalue
---

# hexDigitValue

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

## Declaration

```swift
var hexDigitValue: Int? { get }
```

## Discussion

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", "Ｆ", "g"] for ch in chars {     print(ch, "-->", ch.hexDigitValue) } // Prints: // 1 --> Optional(1) // a --> Optional(10) // Ｆ --> Optional(15) // g --> nil

## See Also

### Checking a Character’s Numeric Properties

- [isNumber](swift/character/isnumber.md)
- [isWholeNumber](swift/character/iswholenumber.md)
- [wholeNumberValue](swift/character/wholenumbervalue.md)
- [isHexDigit](swift/character/ishexdigit.md)
