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

php - Webix Data Loading from Laravel Link -

libGdx unable to find files in android application data directory -

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