How to tell if a client system is 32 or 64 bit?

How to tell if a client system is 32 or 64 bit in Swift?

I couldn't find anything in the documentation and it was hard for me to find a solution. So post your answer below.

+3


source to share


2 answers


In a 64-bit environment, a CGFloat

is the same size as Double

. In a 32-bit environment, it is the same size as Float

. There is a constant CGFLOAT_IS_DOUBLE

, which is therefore 1

on a 64-bit system.



let bit = 32 + (32 * CGFLOAT_IS_DOUBLE)

      

+3


source


The size is Int

guaranteed to be the same size as the native platform dictionary. see docs .

So this should work:



let bit = sizeof(Int) * Int(BYTE_SIZE)
let is64bit = sizeof(Int) == sizeof(Int64)
let is32bit = sizeof(Int) == sizeof(Int32)

      

+8


source







All Articles