JoeBayLD JoeBayLD - 2 months ago 32
Swift Question

Hex to Decimal - Swift

Sorry if this seems really simple, I just can't find it anywhere online.

I have a UInt8 in hex, I need to get it to a decimal. How do I achieve this in swift?

For example:



Rob Rob

If you have a string representation, "ff", you can use UInt8(_:radix:):

let string = "ff"
if let value = UInt8(string, radix: 16) {