-1

I am trying to convert an Int64 value into hex using String(format:)

Here is an example:

let value: Int64 = 431181030500

let stringHex = String(format: "%02X", value) //returns 64646464 instead of the expected 6464646464

Has anyone experienced this? Is there some other way of converting to hex in swift?

Xaxxus
  • 1,083
  • 12
  • 19

1 Answers1

0

I found a solution:

there is a string initializer String(radix:uppercase:) that seems to work fine.

String(431181030500, radix: 16, uppercase: true) // returns 6464646464

I am a bit concerned that String(format:) is returning the wrong value though.

Xaxxus
  • 1,083
  • 12
  • 19