java - How to convert Int bit pattern to Float in Swift? -


i'm looking equivalent of java's float.intbitstofloat(int) in swift.

i've tried:

let myint: uint32 = ... let myfloat = float(_bits: myint) 

but gives me compiler error, "cannot convert value of type 'uint32' expected argument type 'fpieee32'".

is there easy way missing?

update: in swift 3, can do:

float(bitpattern: myint) 

after doing digging of @martinr, there appear 2 (rather ugly) swift solutions:

float._frombitpattern(myint) 

and

unsafebitcast(myint, float.self) 

the former solution no longer appears documented in public api. therefore, latter seems better approach.


Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -