First off, the number you'd like to print out like a long
is too big for even a UInt64
(where the max is print(UInt64.max) // 2^64 = 18446744073709551615
).
If you really want to print out large values, try using a Decimal
type. Here's some code that worked for me:
import UIKit
var str = "Hello, playground"
let doubleValue = Double(23450000000000000000)
Swift.print("hello")
Swift.print(doubleValue)
Swift.print(String(format: "%.0f", doubleValue))
var decimalValue = NSNumber(value: doubleValue).decimalValue
var result = Decimal()
NSDecimalRound(&result, &decimalValue, 0, .plain)
Swift.print(result)
which I dug up by looking at Yervand's answer to this related post
If you try even larger numbers, like "234500000000000000000000
" (a few extra zeros in there), then you'll see the value of doing that NSDecimalRound
.
If you simply want to print out your doubleValue in lldb, try doing po String(format: "%.0f", doubleValue)
at a breakpoint where doubleValue
is defined and you should have decent luck.