I want to have the integer value of the following floating point value:
var floatingPointValue = NSDate().timeIntervalSince1970 * 1000
I don't care if the integer value of this floating point number is actually an integer or a string.
I want to have the integer value of the following floating point value:
var floatingPointValue = NSDate().timeIntervalSince1970 * 1000
I don't care if the integer value of this floating point number is actually an integer or a string.
Int64
is large enough to hold a time interval of some million
years measured in milliseconds:
let milliSeconds = Int64(someDate.timeIntervalSince1970 * 1000)
let milliSecondsString = String(milliSeconds)
Int64 is enough to hold the value you needed
let floatingPointValue = NSDate().timeIntervalSince1970 * 1000
let intValue = Int64(floatingPointValue)
The crucial part is to use Int64
instead of Int
on 32-bit platforms. It will allow you to use 8 bytes of memory (from −9223372036854775808 to +9223372036854775807)
Int64(NSDate().timeIntervalSince1970 * 1000)