JoeBayLD JoeBayLD - 1 year ago 113
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
Answer Source

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

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