String() has a format: init variant:
let myNum = 0x85f3
let numString = String(format:"%08x", myNum)
print( "The number is: \(numString)")
// prints: The number is: 000085f3
Although, in playground (7.3.1, swift 2.2) this doesn't work quite right:
// prints: The number is: ("%08x", 34291)\n"
On 5/25/16 1:16 PM, Ken Burgett via swift-users wrote:
I really shouldn't have to ask this question for a variety of other
languages, but print format conversion in Swift a black box to me.
I wish to print a 64-bit unsigned integer as 8 hexadecimal digits, and
I can't find any documentation on this. Please advise.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users